HELP WITH CODING FOR VIBRATION SENSOR!!!!

To whoever this may concern,

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
}

Please help! Much appreciation (:

Where is the code to do something after you take a reading here?

lightLevel = analogRead (A0);

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
  }
}

I'll try that! Thank you very much for replying :smiley:
I'll let you know later in the week, thank u very much :)))

Hi I tried this out and sorry, it did not work. It compiled with errors and when they were fixed, the entire system did not make a sound.

Did you forget something?

I don't think so but I'm still not sure how to make the LED light flash when i put my finger on the module

AWOL:
Did you forget something?

bakalinks:
I don't think so

I think AWOL's asking you to post the current code. (You have to get used to reading between the lines in some forum posts :frowning: )

I do not often use forums, i am sorry :cry:

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
)
}

  if lightLevel 0<=1;

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: "( )"

And one less of these: ";"