hi im trying to find a code that will alow me to blink an led when my arduino recevies an analog input from an exelerometer any tips or code would be helpfull. thanks. i got the folowing snipit from another member but ive been strugaling to incorporate in to a full runable code. :-?
int analogVal = analogRead(somePin);
if(analogVal > someRandomNumber)
{
// Do some random thing
}
I am far from an expert, but giving it a try anyways
int ledPin = 13; // LED connected to digital pin 13
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
int analogVal = analogRead(somePin);
if(analogVal > someRandomNumber) {
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
}
}