Hoppa till innehållet

KY-002: Skillnad mellan sidversioner

Rad 15: Rad 15:
<pre>
<pre>
int LED = 13 ;// define LED pin
int LED = 13 ;// define LED pin
int SHOCK = 2; // vibration sensor pin
int SENSOR = 2; // sensor pin
int val ; // define numeric variable val
int val ; // define numeric variable val
void setup ()
void setup ()
{
{
   pinMode (LED, OUTPUT) ; // define LED as output  
   pinMode (LED, OUTPUT) ; // define LED as output  
   pinMode (SHOCK, INPUT) ; // define SHOCK as input
   pinMode (SENSOR, INPUT) ; // define SENSOR as input
}
}
void loop ()
void loop ()
{
{
   val = digitalRead (SHOCK) ;// read SHOCK and put it into val
   val = digitalRead (SENSOR) ;// read SENSOR and put it into val
   if (val == HIGH) // When the shock sensor detects a signal, LED flashes
   if (val == HIGH) // When the sensor detects a signal, LED flashes
   {
   {
     digitalWrite (LED, LOW);
     digitalWrite (LED, LOW);
124

redigeringar