ArduinoSection4
ArduinoSection4
Arduino Section 4
Eng/ Dalia Tarek
2
Example 1
Code
While(Serial.available()==0){}
int ledPin=13; value = Serial.read();
int value; if (value == '1') {digitalWrite(ledPin,HIGH);}
void setup () else if (value == '0') {digitalWrite(ledPin,LOW);}
{
Serial.begin(9600);
pinMode(ledPin,OUTPUT);
}
void loop ()
{
5
Example 2
Code
sensorValue = analogRead(sensorPin);
const int sensorPin = A0; digitalWrite(ledPin, HIGH);
const int ledPin = 13; delay(sensorValue);
int sensorValue; digitalWrite(ledPin, LOW);
void setup( ) delay(sensorValue);
{ }
pinMode(ledPin, OUTPUT);
}
void loop ( )
{
8
Thank You