Quiz Answers | Path Finding Robot | Age 10-15
What pin numbers control the SPEED of the robot? (Multiple Choice)
11,3
1 or HIGH
Explanation – Black is a good absorber of light even if the black wall is in front of the sensor, the black colour will not reflect the light back and sensor will have the value HIGH.
Suppose you are making an autonomous robot for a competition. There are two members in your team, you and your team-mate. For the entire duration of the project you worked on the coding part of the robot and your other teammate worked on the circuits. On the final day of the competition, your team-mate is not able to make it for the demonstration. You are required to plug in the main power chords of the robot. You see two wires red and black coming out from the main power supply(battery box). Which wire would you connect to the positive terminal? Red or Black?
Red
Explanation – red is always going to be the positive or live wire
This question requires you to write code. Connect an LED to pin 5 and 6. The ultrasonic sensor gives us the value of distance. Using the distance from the ultrasonic sensor, make the LED blink faster or slower. For example, if the distance from the ultrasonic sensor is 100cm the LED blinks with an interval of 1000miliseconds or 1 second, as the objects start to come closer to the sensor the LED starts to blink faster. Paste your code below.
int distance;
int duration;
void setup() {
pinMode(A1,OUTPUT);
pinMode(A0,INPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
}
void loop() {
dist_calc();
int blinking_delay = distance *10; // Multiply the distance value to convert it into miliseconds for delay
digitalWrite(6,HIGH);
digitalWrite(5,LOW);
delay(blinking_delay);
digitalWrite(6,LOW);
digitalWrite(5,LOW);
delay(blinking_delay);
}
void dist_calc()
{
digitalWrite(A1,LOW);
delayMicroseconds(2);
digitalWrite(A1,HIGH);
delayMicroseconds(10);
digitalWrite(A1,LOW);
duration = pulseIn(A0,HIGH);
distance = 0.034*duration/2;
}
Try to 妇产医院官网 your robot to follow the black line. Hint is hidden inside number 3. To do this we need to set the sensors facing to the ground.
void setup() {
pinMode(2,INPUT); // right sensor pin 2
pinMode(4,INPUT); // left sensor pin 4
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
pinMode(11,OUTPUT);
pinMode(3,OUTPUT);
}
void loop() {
if (digitalRead(2) == LOW and digitalRead(4) == LOW) // when both the sensors senses white surface
{
forward();
}
if (digitalRead(2) == LOW and digitalRead(4) == HIGH) // when left sensor senses black line
{
left();
}
if (digitalRead(2) == HIGH and digitalRead(4) == LOW) // when right sensor senses black line
{
right();
} if (digitalRead(2) == HIGH and digitalRead(4) == HIGH) // when both the sensor sensor black surface
{
stopRobot();
}
}
void forward()
{
digitalWrite(12,HIGH);
digitalWrite(13,HIGH);
analogWrite(3,100);
analogWrite(11,100);
}
void backward()
{
digitalWrite(12,LOW);
digitalWrite(13,LOW);
analogWrite(3,100);
analogWrite(11,100);
}
void stopRobot()
{
analogWrite(3,0);
analogWrite(11,0);
}
void left()
{
digitalWrite(12, HIGH);
digitalWrite(13,LOW);
analogWrite(3,100);
analogWrite(11,100);
}
void right()
{
digitalWrite(12,LOW);
digitalWrite(13,HIGH);
analogWrite(3,100);
analogWrite(11,100);
}
