SetNFix
Published © LGPL

Car Steering Wheel Control Unit with Arduino

Car Steering Wheel Control Unit with Arduino with two rotary encoders.

IntermediateFull instructions provided6,487
Car Steering Wheel Control Unit with Arduino

Things used in this project

Hardware components

ATmega328PB microcontroller
Microchip ATmega328PB microcontroller
×1
Arduino UNO
Arduino UNO
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Through Hole Resistor, 27 kohm
Through Hole Resistor, 27 kohm
×1
Capacitor 22 pF
Capacitor 22 pF
×1
16 MHz Crystal
16 MHz Crystal
×1
Capacitor 10 µF
Capacitor 10 µF
×1
Linear Regulator (7805)
Linear Regulator (7805)
×1
Capacitor 100 nF
Capacitor 100 nF
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1
Resistor 1k ohm
Resistor 1k ohm
×1
Multi-Turn Precision Potentiometer- 10k ohms (25 Turn)
Multi-Turn Precision Potentiometer- 10k ohms (25 Turn)
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
PCB Holder, Soldering Iron
PCB Holder, Soldering Iron
Desoldering Pump, Deluxe SOLDAPULLT®
Desoldering Pump, Deluxe SOLDAPULLT®
10 Pc. Jumper Wire Kit, 5 cm Long
10 Pc. Jumper Wire Kit, 5 cm Long

Story

Read more

Schematics

Car Steering Wheel Control Unit with Arduino : Circuit Diagram

You can use this circuit diagram to wire the project

Code

Car Steering Wheel Control Unit with Arduino : Code

Arduino
This is the code to upload the arduino project
/*this car steering wheel audio control buttons is programmed as universal circuit.
 * This can be used to Volume up and down and, to back and next button. The both rotary encoder 
 * swiches are recommended for that purposes. and also more 2 switches are with the rotary encoders.
 * 
 * Programmed by : BMIAK Basnayaka
 * for SetNFix Youtube channel
 * web : http://www.setnfix.com
 * date : 08.06.2021
 * Video Link https://youtu.be/m4KO8INEGUo
 */





//Volume Controler
int testPin=A0;
int volOne = A2;
int volTwo = A1;
 int directionV=0;
 int counterV = 0; 
 int currentStateCLKV;
 int previousStateCLKV; 

//Next and previous Button
#define nextOne A4
#define nextTwo  A3
 int counterN = 0; 
 int currentStateCLKN;
 int previousStateCLKN;

int progSwitch = A5;
int progData=0;

int volUp = 12;
int volDown = 11;
int back = 10;
int next = 9;

int delayMe =0; // Time need to click a button to activate 1000 = 1 second
int delayBtn = 2000; // Time need to click a button to prgramme the buttons 1000 = 1 second



void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);

pinMode(volOne,INPUT);
pinMode(volTwo, INPUT);
pinMode(nextOne,INPUT);
pinMode(nextTwo,INPUT);
pinMode(progSwitch,INPUT);
pinMode(volUp,OUTPUT);
pinMode(volDown,OUTPUT);
pinMode(back,OUTPUT);
pinMode(next,OUTPUT);
pinMode(testPin,OUTPUT);

  previousStateCLKV = digitalRead(volOne);
  previousStateCLKN = digitalRead(nextOne);
}

void loop() {


progData = analogRead(progSwitch);
delayMe = map(progData,0,1023,200,2000);

//Serial.println(delayMe);
volumeControler();
nextPrevious();





//
//delay(1000);

}

  
void volumeControler(){
  //Volume Controler
// Read the current state of inputCLK
currentStateCLKV = digitalRead(volOne);

//Serial.println(currentStateCLKV);

   // If the previous and the current state of the inputCLK are different then a pulse has occured
   if ((currentStateCLKV == LOW)&&(previousStateCLKV==HIGH)){ 
       
//Serial.println(currentStateCLKV);
     // If the inputDT state is different than the inputCLK state then 
     // the encoder is rotating counterclockwise
     if (digitalRead(volTwo)==LOW) { 
           
        digitalWrite(volDown,HIGH);
        analogWrite(testPin,10);
        Serial.println("DOWN");
        delay(delayMe);
        digitalWrite(volDown,LOW);
        analogWrite(testPin,0);
       //previousStateCLKV = currentStateCLKV; 
       
     } else {
      
       // Encoder is rotating clockwise
        digitalWrite(volUp,HIGH);
        analogWrite(testPin,20);
        Serial.println("UP");
        delay(delayMe);
        digitalWrite(volUp,LOW);
        analogWrite(testPin,0);
      // previousStateCLKV = currentStateCLKV; 
     }
//Serial.println(counterV);
   } 
   // Update previousStateCLK with the current state
   previousStateCLKV = currentStateCLKV; 


/*if (directionV == 1){
digitalWrite(volDown,HIGH);
Serial.println("DOWN");
delay(delayMe);
digitalWrite(volDown,LOW);directionV =0;}

if (directionV == 2){
digitalWrite(volUp,HIGH);
Serial.println("UP");
delay(delayMe);
digitalWrite(volUp,LOW);directionV =0;}
*/



}

void nextPrevious(){

// Read the current state of inputCLK
   currentStateCLKN = digitalRead(nextOne);
    
   // If the previous and the current state of the inputCLK are different then a pulse has occured
   if ((currentStateCLKN==LOW) && (previousStateCLKN==HIGH)){ 
       
     // If the inputDT state is different than the inputCLK state then 
     // the encoder is rotating counterclockwise
     if (digitalRead(nextTwo) ==LOW) { 
       counterN --;
        digitalWrite(next,HIGH);
        analogWrite(testPin,30);
        Serial.println("BACK");
        delay(delayMe);
        analogWrite(testPin,0);
        digitalWrite(next,LOW);
       
       
     } else {
       // Encoder is rotating clockwise
       counterN ++;
        digitalWrite(back,HIGH);
        Serial.println("NEXT");
        analogWrite(testPin,40);
        delay(delayMe);
        digitalWrite(back,LOW);
        analogWrite(testPin,0);
       
     }

   } 
   // Update previousStateCLK with the current state
   previousStateCLKN = currentStateCLKN; 
 }

Credits

SetNFix

SetNFix

17 projects • 35 followers
I am an accountant in profession but, I would more prefer to work with electronics based innovations.

Comments