I wrote a little program and made a circuit for the ATTiny which enables a photocell to control an LED and a motor with pulse width modulation.
Here’s the video:
–
And here’s the circuit diagram:
And here’s the code for the Arduino IDE:
int val = 0; int qval = 0; void setup(){ pinMode(1,OUTPUT); digitalWrite(1,LOW); pinMode(0,OUTPUT); digitalWrite(0,LOW); } void loop(){ val = analogRead(1); qval = int(val/4); if (val<200){ qval = 0; } analogWrite(1,qval); analogWrite(0,qval); }
The LED doesn’t seem to ‘fade’ on. Rather, it seems to come on suddenly.