Operácie

Acro02b

Z SensorWiki

Verzia z 09:03, 6. máj 2010, ktorú vytvoril Balogh (diskusia | príspevky)
#define   redLED 2    // LED connected to digital pin 2
#define greenLED 3    // LED connected to digital pin 3
#define   button 7    // SW 1 connected to D7
int state=0;
  
void setup()   {                
  // initialize the digital pins as an outputs:
  pinMode(  redLED, OUTPUT);     
  pinMode(greenLED, OUTPUT);     
  pinMode(  button, INPUT);

// !!! Bez tohoto obyc. tlacitko na zem nefunguje!!!

 digitalWrite( button, HIGH);   // pull-up ON
 
  Serial.begin(9600);
}

void loop()                     
{
 
 
  state = digitalRead(button);     // read the value from the sensor

  Serial.print("Sensor = ");
  Serial.println(state, DEC);
  delay(200);

}


Predošlá úloha... | Späť do menu | Pokračovanie...