0% found this document useful (0 votes)
17 views1 page

Wyndell Rio P. Claveria EE-4204 Activity Practice 1

The document describes code for mapping a sensor value read from an analog pin to an output value and writing it to a pin if a slide switch is high. It initializes pins, reads the sensor, maps the value, and writes it out if the switch is on, printing values to the serial monitor.

Uploaded by

WyndellRio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

Wyndell Rio P. Claveria EE-4204 Activity Practice 1

The document describes code for mapping a sensor value read from an analog pin to an output value and writing it to a pin if a slide switch is high. It initializes pins, reads the sensor, maps the value, and writes it out if the switch is on, printing values to the serial monitor.

Uploaded by

WyndellRio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Wyndell Rio P.

Claveria outputValue = map(sensorValue, 0, 1023, 0,


255);
EE-4204

Activity Practice 1
//code for slide switch

if (digitalRead(2) == HIGH)

digitalWrite(3, HIGH);

analogWrite(3, outputValue);

else

digitalWrite(3, LOW);

}
int sensorValue = 0;

int outputValue = 0;
Serial.print("sensor = ");

Serial.print(sensorValue);
void setup()
Serial.print("\t output = ");
{
Serial.println(outputValue);
pinMode(A1, INPUT);

pinMode(3, OUTPUT);
delay(10);
pinMode(2, OUTPUT);
}
Serial.begin(9600);

void loop()

//code for potentiometer

sensorValue = analogRead(A1);

You might also like