LED Strobe

Here’s the strobe working. The camera is not able to pick up the strobe rate much but at times you can tell.

 

 

Here’s the code:

 

/*
LED attached to D13
Potentiometer attached to A1
*/

int sensorPin = A0;   // potentiometer connected analog pin 1
int ledPin = 13;      // LED is connected to digital pin 13
long lastPrint;       // variable to track how often to print

void setup() {// this function runs once when the sketch starts up
Serial.begin(9600); // so we can talk back to the computer
Serial.println(“LED_and_Potentiometer.pde”);
pinMode(ledPin, OUTPUT);
lastPrint = millis(); // time in ms since reset
}

void loop(){ // this function runs repeatedly after setup() finishes
int sensorValue = analogRead(sensorPin); // get 10-bit reading
digitalWrite(ledPin, HIGH);              // Turn the LED on
delay(sensorValue);                      // Pause for sensorValue in ms
digitalWrite(ledPin, LOW);               // Turn the LED off
delay(sensorValue);                      // Pause for sensorValue in ms

if((millis() – lastPrint) > 1000){// only print once a second
Serial.println(sensorValue);
lastPrint = millis();
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s