Lesson 3
Connecting the model to the Arduino
In this lesson, students:
assemble the sensor wiring diagram
connect the sensors to the board
write a program to display
You can proceed from the level of listeners and suggest connecting sensors to the board without a ready-made template
Sensors are connected according to the principle of a simple button or touch sensor:
one electrode directly to positive (5V)
the second electrode directly to the analog port
a 10K resistor is also connected to the second electrode
the second electrode of the resistor is connected to minus (GND)
Also, depending on the level of listeners, you can try to write a program to display data from sensors
You must use a port monitor to output data
Go to the “Content” section and enter and save the code below:
void setup() {
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
Serial.begin(9600);
}
void loop() {
int lob = analogRead(A0);
int tem = analogRead(A0);
int lev_vis = analogRead(A0);
int prav_vis = analogRead(A0);
int zatyl = analogRead(A0);
Serial.print(lob);
Serial.print(" ");
Serial.print(tem);
Serial.print(" ");
Serial.print(lev_vis);
Serial.print(" ");
Serial.print(prav_vis);
Serial.print(" ");
Serial.println(zatyl);
delay(100);
}
