All I'm doing is using the microcontroller to read a LDR and have 1 of 2 outputs (LEDs) high, while the other is low. It works fine on the Uno, but I put it on the ATTINY85 and it just sits there with pin 0 high, no matter how much light I give/take away from the LDR.
Blink works on the ATTINY, so my setup should be good.
Here is the original code from that is on the Uno, which works perfectly:
const int dooropen=13; // variable which stores pin number
const int doorclose=12; //variable which stores pin numbervoid setup()
{
pinMode(dooropen, OUTPUT); //configures pin 13 as OUTPUT
pinMode(doorclose, OUTPUT); //configures pin 12 as OUTPUT
Serial.begin(9600);
}void loop()
{
int sensor_value = analogRead(A0);
if (sensor_value > 600)// the point at which the state of LEDs change
{
digitalWrite(doorclose, HIGH);
digitalWrite(dooropen, LOW);
}
if (sensor_value < 400)
{
digitalWrite(doorclose,LOW); //Sets LEDs OFF
digitalWrite(dooropen, HIGH);
}
Serial.println(sensor_value);
delay(500);}
I tried the original code (changed pin numbers), no joy. I then simplified the code as best I could to this
void setup()
{
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
}void loop()
{
int sensor_value = analogRead(4); //convenient placement on board
if (sensor_value > 600){digitalWrite(0, LOW);
digitalWrite(1, HIGH);
}
if (sensor_value < 400){
digitalWrite(1,LOW);
digitalWrite(0, HIGH);
}}
Still no joy, sits there with pin 0 LED on.
I am working on this with my 10 year old, we are learning Arduino together, but we take such long breaks inbetween touching it that I forget pretty much everything.
