V1 Rotary Encoder Using Attiny Microcontroller
by heemanthy in Circuits > Electronics
516 Views, 1 Favorites, 0 Comments
V1 Rotary Encoder Using Attiny Microcontroller
i made a rotary encoder generator using attiny microcontroller which can be used for simulation in proteus and tinkercad as there no encoder wheel viable in them
Supplies
this are the list of materials required
Downloads
Attiny Schematic
at here you see the connection you can use the .brd file in tinkercad
Source Code
at here you can there is a simple code given for the attiny
// C++ code
//
void setup()
{
pinMode(4, INPUT);
pinMode(3, INPUT);
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(5, INPUT);
}
void loop()
{
if (digitalRead(4) == HIGH) {
if (digitalRead(3) == HIGH) {
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(0, LOW);
digitalWrite(0, LOW);
digitalWrite(0, HIGH);
delay(100); // Wait for 100 millisecond(s)
}
if (digitalRead(5) == HIGH) {
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, HIGH);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(0, HIGH);
digitalWrite(0, LOW);
digitalWrite(0, LOW);
delay(100); // Wait for 100 millisecond(s)
}
} else {
if (digitalRead(3) == HIGH) {
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(0, HIGH);
digitalWrite(0, LOW);
digitalWrite(0, LOW);
delay(100); // Wait for 100 millisecond(s)
}
if (digitalRead(5) == HIGH) {
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(0, LOW);
digitalWrite(0, LOW);
digitalWrite(0, LOW);
delay(100); // Wait for 100 millisecond(s)
}
}
}
Downloads
Link to the Circuit
https://www.tinkercad.com/things/co9FU5KTbk5