21
8.
Time for another example! Copy the program Fourth.pde shown in Figure 3.4.
9.
Look at the use of the
if
,
else
if
, and
else
statements. Does it make sense?
void setup()
{
Serial.begin(9600);
}
void loop()
{
int var1;
var1 = 3;
Serial.print("var1 = ");
Serial.print(var1, DEC);
if( var1 == 1)
{
Serial.println(" is equal to 1");
}
else if( var1 < 1)
{
Serial.println(" is less than 1");
}
else if( var1 <= 4)
{
Serial.println(" is less than or equal to 4");
}
else
{
Serial.println(" unknown");
}
delay(1000);
}
Figure 3.4: Program – Fourth.ino
Содержание Pi-Bot v2.00
Страница 67: ...67 Figure 6 15 ...
Страница 78: ...78 UltraSonicSensorTestwithLED Program ...
Страница 80: ...80 ObstacleAvoidance Program ...
Страница 82: ...82 ObstacleAvoidancewithLED Program ...
Страница 83: ...83 ObstacleAvoidancewithLED Program CONTINUED ...
Страница 90: ...90 Download and run the following program LineFollowing Program ...
Страница 91: ...91 LineFollowing Program CONTINUED ...
Страница 94: ...94 AdvancedLineFollowing Program CONTINUED ...
Страница 95: ...95 AdvancedLineFollowing Program CONTINUED ...
Страница 96: ...96 AdvancedLineFollowing Program CONTINUED ...
Страница 110: ...Appendix B Complete Pi Bot Wiring Schematic ...