Hi,
Every time I try and run my Uno on a 9V battery or any form of external power supply, an LED flashes 3 times with a pause in between.
The board runs my sketches fine via the USB cable but as soon as I unplug the USB and try to run off external supply, the above happens.
Here is the code that I am trying to run.
const int echoPin = 10; //const because it is Read only
int val = 0;
int leftPin = 3;
int rightPin = 4;
int trigPin = 12; //because it changes
long duration; //to calculate distance
long HR_dist = 0; //calculated distance
void setup()
{
delay(500);
//establish comms
pinMode(echoPin, INPUT);
pinMode(leftPin, OUTPUT);
pinMode(rightPin, OUTPUT);
pinMode(trigPin, OUTPUT);
}
void loop()
{
delay(500);
{
long duration; //establish the variable
}
//sensor is triggered by a HIGH pulse of 10 or more m/s.
//First give a short LOW pulse beforehand to ensure a clean
//HIGH pulse
pinMode(trigPin, OUTPUT);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
//Read the signal from the sensor: a HIGH pulse whose
//duration is the time from the sending of the ping from trigPin
//to the reception of echoPin off a real world object
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
if (duration >=1000)
{
digitalWrite (leftPin, HIGH);
digitalWrite (rightPin, HIGH);
}else{
digitalWrite (leftPin, LOW);
digitalWrite (rightPin, LOW);
}
}