Hi trying to get this project to work in reality works fine on tinkercad must be missing something! Have 2 switches controlling 2 outputs if either 1 of inputs are high then switch on both outputs. If both outputs low both outputs off. This only switches on outputs when both switches high. This coding is all new to me and i guess i'm missing something simple that tinkercad isnt picking up.
Thanks
// C++ code
//
void setup()
{
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(2, OUTPUT);
pinMode(1, OUTPUT);
}
void loop()
{
if (digitalRead(4) == HIGH || digitalRead(5) == HIGH) {
digitalWrite(2, HIGH);
digitalWrite(1, HIGH);
} else {
digitalWrite(2, LOW);
digitalWrite(1, LOW);
}
delay(10); // Delay a little bit to improve simulation performance
Pinout is the same as a 13a,
GPIO 5 / pin 1 should be above 2.5v or the AtTiny will reset.
You can set the fuses to use it as a normal IO pin, but thereafter you will not be able to upload any code to it anymore, so that is not recommended.
Basically you don't need it at all for this project, you have 5 digital GPIO pins available, and you only need 4. PB5/Reset should be pulled up for a stable system (use a 10K resistor)
edit:
The PB5/reset can be used as an analog input though and is reference by A0, but still only as long as the voltage stays above 2.5v (on a 5v powered chip), a few extra resistors can help you out with this.
That was my problem as i had an input to pb5 which was either 0v or 5v depending on switch on or off. swapped my switches to pb3&pb4 and left pb5 at 5v it now functions correctly. Thanks
`// C++ code
//
void setup()
{
pinMode(4, INPUT);
pinMode(3, INPUT);
pinMode(2, OUTPUT);
pinMode(1, OUTPUT);
}
void loop()
{
if (digitalRead(4) == HIGH || digitalRead(3) == HIGH) {
digitalWrite(2, HIGH);
digitalWrite(1, HIGH);
} else {
digitalWrite(2, LOW);
digitalWrite(1, LOW);
}
delay(10); // Delay a little bit to improve simulation performance
}`
If i wanted to add a delay of say 10 seconds before switching output on and off