I am very grateful if you could help me with my coding.
I currently own the "Eleven" (100% Arduino Uno Compatible)and my project contains:
1 x LED light
10 x Jumper wires
1x Resistor
1 x Sensor Module
1 x Piezo Module
I am making a project and its purpose is to produce sound and light whenever my finger touches the sensor. The issue is that the LED light constantly blinks but I want it to flash once my finger has touched the sensor and I'm not quite sure had to do that in my coding.
This is my current code, My LED light is inserted in 13
int lightLevel;
int piezo = 8;
int duration = 300;
int notes = (500, 400);
void setup ()
{
pinMode (piezo, OUTPUT);
}
void loop ()
{
lightLevel = analogRead (A0);
tone (piezo, notes, duration);
delay (duration);
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
}
CrossRoads:
Where is the code to do something after you take a reading here?
lightLevel = analogRead (A0);
I thought I included that? Sorry I am very new to the whole concept, another bug is to be that the sound stops when I place my finger on the sensor whereas I want it to do the opposite: For my device to produce sound and light when my finger is on the sensor
I don't see anything. Perhaps you intended something like this:
void loop ()
{
lightLevel = analogRead (A0);
if (lightLevel >=512){
tone (piezo, notes, duration);
delay (duration);
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
}
}
int lightLevel;
int piezo = 8;
int duration = 300;
int notes = (500, 400);
void setup ()
{
pinMode (piezo, OUTPUT);
}
void loop ()
{
if lightLevel 0<=1;(
pinMode (piezo, OUTPUT);
tone (piezo, notes, duration);
delay (duration);
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
)
}
I imagine the compiler didn't like that.
I don't like that - I can't even work out what it's meant to look like, but I imagine it involves at least a pair of these: "( )"