703
edits
m (Created page with "=== resistive Sensor === File:Resistive_Sensor_Steckplatine.png <source lang="c"> int mySensorValue; void setup () { Serial.begin(); } void loop () { mySensorValue = ...") |
mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
== resistive Sensor == | |||
[[File:Resistive_Sensor_Steckplatine.png|thumb]] | |||
[[File:Potentiometer_A0_Serial_Steckplatine.png|thumb]] | |||
Recipe for resistive sensor: | |||
* Pick a resistive sensor | |||
* Measure its lowest and highest resistance using a multimeter. | |||
* Write the name of the sensor and the maximum and minimum resistance on the black board. | |||
* pick a resistor which has the same value as the sensor on its highest value | |||
* Use the below code and create the circuit for a resistive sensor | |||
* open the serial monitor and have a look at the values. | |||
* try larger and smaller resistors and see the difference. | |||
* use an other sensor (one that is already listed on the black board) | |||
Recipe for Potentiometer: | |||
* connect the Potentiometer as displayed on the right. | |||
* use the same program as before for the analog sensor | |||
* see what values you get - compare with values from the resistive sensor. | |||
<source lang="c"> | <source lang="c"> | ||
Line 8: | Line 26: | ||
void setup () { | void setup () { | ||
Serial.begin(); | Serial.begin(9600); | ||
} | } | ||
Line 17: | Line 35: | ||
} | } | ||
</source> | </source> | ||
<br clear="all"> | |||
== switch or Button == | |||
[[File:Button_1k_Pullup_Steckplatine.png|thumb]] | |||
<source lang="c"> | |||
int mySensorValue; | |||
void setup () { | |||
Serial.begin(9600); | |||
pinMode(13,OUTPUT); | |||
pinMode(4,INPUT); | |||
} | |||
void loop () { | |||
mySensorValue = digitalRead(4); | |||
if (mySensorValue == LOW) { | |||
Serial.println("The Button is pressed. "); | |||
digitalWrite(13,HIGH); | |||
} | |||
else { | |||
Serial.println("The Button is not pressed"); | |||
digitalWrite(13,LOW); | |||
} | |||
} | |||
</source> | |||
<br clear="all"> |
edits