Hi All,
I have programmed quite a bit but am running into an issue I have never had before with an ATtiny chip.
I am using arduino to write to the chip using a Sparkfun AVR, I was using the sparkfun library and was having the issue switch to adafruits library, and am now on the SpenceKonde/ATTinyCore library.
What I am running into is that the digital read does not appear to be working. I have simplified the code to just turn the LEDs off if the button is pressed. I also used analogWrite on one and digital on the other to see if I had something weird there.
This is the code:
const int redLED = 0;
const int greenLED = 1;
const int button = 2;
const int relayRelease = 4;
int count = 0;
int greenInt = 168;
int redInt = 107;
void setup()
{
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
pinMode(button, INPUT);
pinMode(relayRelease, OUTPUT);
}
void loop()
{
analogWrite(redLED, redInt);
analogWrite(greenLED, greenInt);
delay(1000);
while (digitalRead(button == HIGH))
{
analogWrite(greenLED, 0);
digitalWrite(redLED, LOW);
delay(1000);
}
}
When I press the button nothing happens, I can measure 5v at the pin ( measured after the button) so I know it is high. As a second test I changed while (digitalRead(button == HIGH)) to while (digitalRead(button == LOW)) still nothing happens.
I at one point added a flash sequence after the while loop to make sure the code was reading through. This worked but the button would still not affect the LEDs.
Is there something I am missing? To my knowledge all the pins on an ATtiny can function as digital I/O.
Thanks