30
edits
Changes
no edit summary
Unfortunately, today as the day I will present my project, my freeduino board got burnt and stopped working in the morning. I can no longer use Arduino for my project. For now, I just put the whole set up with LEDs without interacting with the sensor or blinking lightshow. I still post the Arduino code that I had put together the past couple days, so you can understand what I intend to do, and how the project actually worked before the board was damaged.
int timer = 100;
void setup() {
Serial.begin(9600);
for (int thisPin = 2; thisPin < 9; thisPin++) {
pinMode(thisPin, OUTPUT);
}
}
void loop() {
int sensorReading = analogRead(2);
// print the sensor reading so you know its range
Serial.println(sensorReading);
int thisRange = map(sensorReading, 1, 50000, 1, 50000);
// loop from the lowest pin to the highest:
byte brightness = thisRange;
for (int thisPin = 2; thisPin < 9; thisPin++) {
analogWrite(thisPin, brightness);
}
for (int thisPin = 2; thisPin < 9; thisPin++) {
// turn the pin on:
digitalWrite(thisPin, HIGH);
delay(thisRange*3);
// turn the pin off:
digitalWrite(thisPin, LOW);
analogWrite(thisPin, brightness);
}
// loop from the highest pin to the lowest:
for (int thisPin = 9; thisPin >= 2; thisPin--) {
// turn the pin on:
digitalWrite(thisPin, HIGH);
delay(thisRange*3);
// turn the pin off:
digitalWrite(thisPin, LOW);
analogWrite(thisPin, brightness);
}
}