http://youtu.be/0tCH0Vq0Uok
Self Aware LED Array Arduino Code
[sourcecode language="java"]
int led1 = 13;
int led2 = 12;
int led3 = 11;
int led4 = 10;
int pcpin = 0;
int pcread;
int x = 0;
void setup() {
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(pcpin, INPUT);
}
void log() {
pcread = analogRead(pcpin);
Serial.print("Photocell light level = ");
Serial.println(pcread);
delay(150);
}
void loop() {
log();
digitalWrite(led1, HIGH);
log();
digitalWrite(led1, LOW);
log();
digitalWrite(led2, HIGH);
log();
digitalWrite(led2, LOW);
log();
digitalWrite(led3, HIGH);
log();
digitalWrite(led3, LOW);
log();
digitalWrite(led4, HIGH);
log();
digitalWrite(led4, LOW);
}
[/sourcecode]
Just open up a serial monitor to watch your Arduino watch itself o_0
No comments:
Post a Comment