Operácie

Acro02b: Rozdiel medzi revíziami

Z SensorWiki

(Nová stránka: <source lang="cpp"> #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 ...)
 
Riadok 30: Riadok 30:
 
}
 
}
 
</source>
 
</source>
 +
 +
 +
[[Acrob02|Predošlá úloha...]] | [[Acrob|Späť do menu]] | [[Acrob03|Pokračovanie...]]

Verzia zo dňa a času 09:03, 6. máj 2010

#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...