CONSTRUCTION GUIDE Light Robot. Robobox. Level VI

Similar documents
CONSTRUCTION GUIDE Capacitor, Transistor & Motorbike. Robobox. Level VII

100UF CAPACITOR POTENTIOMETER SERVO MOTOR MOTOR ARM. MALE HEADER PIN (3 pins) INGREDIENTS

CONSTRUCTION GUIDE Robotic Arm. Robobox. Level II

1. Introduction to Analog I/O

Lab 06: Ohm s Law and Servo Motor Control

Arduino and Servo Motor

A servo is an electric motor that takes in a pulse width modulated signal that controls direction and speed. A servo has three leads:

Arduino: Sensors for Fun and Non Profit

CONSTRUCTION GUIDE IR Alarm. Robobox. Level I

Objectives: Learn what an Arduino is and what it can do Learn what an LED is and how to use it Be able to wire and program an LED to blink

Pulse Width Modulation and

Project #6 Introductory Circuit Analysis

Lesson 13. The Big Idea: Lesson 13: Infrared Transmitters

Computational Crafting with Arduino. Christopher Michaud Marist School ECEP Programs, Georgia Tech

1. Controlling the DC Motors

LED + Servo 2 devices, 1 Arduino

CURIE Academy, Summer 2014 Lab 2: Computer Engineering Software Perspective Sign-Off Sheet

Two Hour Robot. Lets build a Robot.

Coding with Arduino to operate the prosthetic arm

Attribution Thank you to Arduino and SparkFun for open source access to reference materials.

Arduino Control of Tetrix Prizm Robotics. Motors and Servos Introduction to Robotics and Engineering Marist School

You'll create a lamp that turns a light on and off when you touch a piece of conductive material

INA169 Breakout Board Hookup Guide

Sten BOT Robot Kit 1 Stensat Group LLC, Copyright 2016

Sten-Bot Robot Kit Stensat Group LLC, Copyright 2013

FABO ACADEMY X ELECTRONIC DESIGN

Mechatronics Engineering and Automation Faculty of Engineering, Ain Shams University MCT-151, Spring 2015 Lab-4: Electric Actuators

For this exercise, you will need a partner, an Arduino kit (in the plastic tub), and a laptop with the Arduino programming environment.

Module: Arduino as Signal Generator

Programming 2 Servos. Learn to connect and write code to control two servos.

Parts List. Robotic Arm segments ¼ inch screws Cable XBEE module or Wifi module

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

Control Robotics Arm with EduCake

Internet of Things Student STEM Project Jackson High School. Lesson 3: Arduino Solar Tracker

Project 27 Joystick Servo Control

J. La Favre Using Arduino with Raspberry Pi February 7, 2018

Roborodentia Robot: Tektronix. Sean Yap Advisor: John Seng California Polytechnic State University, San Luis Obispo June 8th, 2016

The Motor sketch. One Direction ON-OFF DC Motor

HAW-Arduino. Sensors and Arduino F. Schubert HAW - Arduino 1

Experiment 1: Robot Moves in 3ft squared makes sound and

Blink. EE 285 Arduino 1

Lab 2.4 Arduinos, Resistors, and Circuits

Sunday, November 4, The LadyUno Sound Unit

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

Introduction: Components used:

TWEAK THE ARDUINO LOGO

C++ PROGRAM FOR DRIVING OF AN AGRICOL ROBOT

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

Lecture 4: Basic Electronics. Lecture 4 Brief Introduction to Electronics and the Arduino

Lab 2: Blinkie Lab. Objectives. Materials. Theory

Lab 5: Arduino Uno Microcontroller Innovation Fellows Program Bootcamp Prof. Steven S. Saliterman

Programming a Servo. Servo. Red Wire. Black Wire. White Wire

4WD Mobile Platform SKU:ROB0022

Grove - Infrared Receiver

Mechatronics Project Report

CPSC 226 Lab Four Spring 2018

Introduction to. An Open-Source Prototyping Platform. Hans-Petter Halvorsen

PHYSICS 124 PROJECT REPORT Kayleigh Brook and Zulfar Ghulam-Jelani

Arduino An Introduction

EE-110 Introduction to Engineering & Laboratory Experience Saeid Rahimi, Ph.D. Labs Introduction to Arduino

LEDs and Sensors Part 2: Analog to Digital

Arduino Sensor Beginners Guide

Setup Download the Arduino library (link) for Processing and the Lab 12 sketches (link).

Drawbot DC Motor Servo Motor Creative Design 03 Interactive Digital Prototyping Junior Software Academy. 10 Drowbot 121 MIC

Lesson4 Obstacle avoidance car

The Robot Builder's Shield for Arduino

Arduino Workshop 01. AD32600 Physical Computing Prof. Fabian Winkler Fall 2014

Lecture 6. Interfacing Digital and Analog Devices to Arduino. Intro to Arduino

Advanced Mechatronics 1 st Mini Project. Remote Control Car. Jose Antonio De Gracia Gómez, Amartya Barua March, 25 th 2014

02 Digital Input and Output

Arduino Setup & Flexing the ExBow

Embedded Controls Final Project. Tom Hall EE /07/2011

APDS-9960 RGB and Gesture Sensor Hookup Guide

Robotic Arm Assembly Instructions

Nano v3 pinout 19 AUG ver 3 rev 1.

Community College of Allegheny County Unit 7 Page #1. Analog to Digital

Community College of Allegheny County Unit 4 Page #1. Timers and PWM Motor Control

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

Lesson 3: Arduino. Goals

MicroWave Sensor SKU: SEN0192

Megamark Arduino Library Documentation

Portland State University MICROCONTROLLERS

PLAN DE FORMACIÓN EN LENGUAS EXTRANJERAS IN-57 Technology for ESO: Contents and Strategies

Arduino Intermediate Projects

Adafruit 16-Channel Servo Driver with Arduino

Workshops Elisava Introduction to programming and electronics (Scratch & Arduino)

Rodni What will yours be?

Arduino DC Motor Control Tutorial L298N PWM H-Bridge

The µbotino Microcontroller Board

Today s Menu. Near Infrared Sensors

Lesson 2 Bluetooth Car

Arduino Advanced Projects

Demon Pumpkin APPROXIMATE TIME (EXCLUDING PREPARATION WORK): 1 HOUR PREREQUISITES: PART LIST:

Basics before Migtrating to Arduino

Disclaimer. Arduino Hands-On 2 CS5968 / ART4455 9/1/10. ! Many of these slides are mine. ! But, some are stolen from various places on the web

Learning Objectives. References 10/26/11. Using servos with an Arduino. EAS 199A Fall 2011

Lets start learning how Wink s bottom sensors work. He can use these sensors to see lines and measure when the surface he is driving on has changed.

Analog Feedback Servos

digitalread() EE 285 Arduino 1

DFRduino Romeo All in one Controller V1.1(SKU:DFR0004)

Transcription:

CONSTRUCTION GUIDE Light Robot Robobox Level VI

The Light In this box dedicated to light we will discover, through 3 projects, how light can be used in our robots. First we will see how to insert headlights on our autonomous car, then we will mount a light robot capable of following the sun. Finally, we will insert a line follower to the front of our car. 3X 33Ω resistor 3X line Follower 2X LEDs 3X Photoresistor x Robot Body 3X Male-Male Cables Parts 2X Male-Female X Robot Head Cables X Female block X Footer X headlight Block X Line follower block X Stabilizer Instructions We suggest that you follow these instructions step by step. Additional details are available on your member space on Robobox.io. Please don t hesitate to ask any question, we will answer them promptly. Good luck!

Car Lights NTRDUCTN On modern cars, it is possible to ask the on-board computer to automatically adjust the headlights according to the surrounding brightness. We will try to do the same for our robot! For this, we will use a photoresistor included in the box. A photoresistor is a resistor whose value (in Ohm) varies depending on the brightness of the part. Specifically, the resistance decreases as the brightness increases. In our case, we want to increase the intensity of the headlights when the brightness drops, so we will use our Arduino card to reverse this relationship between resistance and current. Diagram: Photoresistor In a first step we define our variables. We will need to define the Pin that will receive the value of the photoresistor (between and 23), we will then store this data in the variable valuephoto.

Car Lights CODE In a second step, we will turn on the LED linked to the pinled pin with an intensity defined by the luminositeled variable. After starting communication with the serial port, we will recover the brightness using the analog ports to the left of the card. Then we will convert this value from to 23 in an intensity between and 255. The lower the luminosity of the room and the stronger our lighting. During our tests, we noticed that the luminosity of the room was around 5 on the scale from to 23, so we adapted our function to this value. To convert a value from one scale to another, we use the map() function. 49 5 255 254 Finally, we send the desired intensity signal to the LED with the analogwrite() function. The latter sends a signal between and 5V to the pins of the card with a tilde: '~'. These pins use the Pulse-Width Modulation (PWM) to transform a digital signal (/) into an analog signal (/255) by alternating V and 5V signals. int pinphoto = ; int valuephoto; int pinled = ; int luminositeled; void setup() { Serial.begin(96); void loop() { valeurphoto = analogread(pinphoto); Serial.print("Analog reading = "); Serial.print(valuePhoto); luminositeled = max( map(valuephoto,, 5, 255, ), ); Serial.print(" Analog write = "); Serial.println(luminositeLed); analogwrite(pinled, luminositeled); delay();

Car Lights _2_ BUILD Now that we understand how a photoresistor works, we will be able to install the automatic headlights on our robot car. Insert the 2 LEDs of the box inside the headlight block then: Slide female-female wire between the short leg of the left LED and the long leg of the right LED. () Plug a male-female wire into the long leg of the left LED (2) Plug a male-female wire into the short leg of the right LED. (3) (2) () (3) We will then connect the wire (2) to the current source and the wire (3) to ground. We will then use the circuit from month 4 and we will add the photoresistor. As illustrated below, when the brightness varies, the resistance in the circuit changes and therefore the voltage measured in A differs. 5V A GND

Car Lights _3_ CODE Finally, we have to slide the headlight block to the front of the vehicle. To do this, we must first add a female triangle block to the front of the car. Then you only have to add the headlight block as illustrated opposite: To allow your car to automatically turn on its headlights thanks to the luminosity of the room, simply add these few lines of code at the beginning of the program: int pinphoto = A; int valeurphoto; int pinled = 3; int luminositeled; Then set the function LigthsOn() which will turn on or off the headlights of our vehicle when it is in a dark room: void LightsOn() { valeurphoto = analogread(pinphoto); luminositeled = max( map(valeurphoto,, 3, 255, ), ); analogwrite(pinled, luminositeled); delay(); Finally, simply add the function LightsOn() in the loop like this: You can retrieve all the code on teamrobobox, see the videos of the car in motion and ask all the questions to help you in the construction of this robot! There you go! Your car is now able to turn on its headlights when it is in a dark room! void loop() { curdist = distanceread(); LigthsOn(); if (curdist > 2){ forward(); if (curdist < 2){ backward(); turnright(); delay(3);

Line Follower INTRODUCTION Let's see a new component: the line follower. The line follower is a module consisting of an infrared emitting LED and an infrared receiver. The infrared LED continuously illuminates the surface in front of which it is oriented and the receiver indicates whether or not it perceives the reflection of a light. As you surely know, white reflects all the light it receives while black absorbs it. So when your infrared LED illuminates a white surface, the receiver will detect a signal and when the surface is dark, the receiver will not detect anything. Transmitter Receiver Transmitter Receiver Our challenge here is to set up a line detector on our car to make it follow a black line on the ground. For this challenge we will need a block and three line follower modules. First, push the modules into the appropriate block and place it in the front of the vehicle (just like the headlights). Then connect the GND and 5V cables of the modules to the breadboard (in series with the other GND and 5V). Finally, connect the receiver cables (green) to the analog pins, and 2. A A GND 3.3V A2

Line Follower _2_ BUILD Before the setup() function: int pinlined = A; int pinlinec = A; int pinlineg = A2; int instr[2]; In the setup() function: pinmode(pinlined,input); pinmode(pinlinec,input); pinmode(pinlineg,input); Now we are interested in programming our vehicle. The purpose of the code will be to follow a black line using the three sensors. So : - The sensor of the center reads a black line whereas those on the sides don t, the car must go straight ahead. - Only one of the lateral sensors identifies a black line, the car should turn in that direction. - None of the sensors see a line, the car is out of track and must therefore retreat. After the loop() function: void forward(int mot, int mot2 ){ dirmoteur(,,mot); dirmoteur(2,,mot2); In the loop(): void loop() { int check = checkline(); if (check == ){ forward(instr[],instr[]); Before the setup() function we will add three global variables, pinlineg, pinlined and pinlinec, initialized to A, A and A2, which will correspond to the input pin of the sensor signal. We also create an array instr[2] in which we will write the instructions for the engines. Then we will specify in the setup() function that these pins will be used as input. Then, we create the advance function(int word, int word2) which has two arguments word and word2. These two integers tell you how fast the right and left wheels go. Inside the loop(), we run a checkline() function whose purpose is to update the instructions for the motors and return '' if the sensor has read the data. Finally, we ask the car to proceed at the speed set in the checkline() function.

Line Follower Now we will create the checkline() function. This function will probe the values of the line sensors and turn it into an instruction for the car. Connected to the 3.3V, sensors return a value of about 645 if no line is seen, and a lower value (between 2 and 5) if a line is present. First, we will transform any value less than 62 into zero and any higher value into. _3_ CODE int checkline(){ int lineg = (analogread(pinlineg)>62)?():(); int linec = (analogread(pinlinec)>62)?():(); int lined = (analogread(pinlined)>62)?():(); int Recept[4] = {lineg,linec,lined,; int mat[2][4] = {{2,8,6,,{6,8,2,; int motor[2] = {,; for(int i = ; i<2; i++){ for( int j = ; j<4; j++){ motor[i] = motor[i] + ( mat[i][j] * Recept[j]) ; instr[] = motor[]; instr[] = motor[]; if (( motor[] + motor[]) == ){return ; return ; We end up with a vector of 3 booleans (for example: [,,]) corresponding to the 3 sensors. We will also add a fourth integer :. We will then multiply this vector by a matrix to deduce the speeds to apply to our engines: Line detected in the center: Line detected left: Line detected in center + left: 2 6 8 8 6 2 = 2 + 8 + 6 + + ( 6 + 8 + 2 + ) = (8, 8) Line detected to the right: Line detected in the center + right: 2 6 8 8 6 2 2 6 8 8 6 2 = (2, 6) = (6, 2) The instructions for our car are now set! 2 6 8 8 6 2 2 6 8 8 6 2 = (, 4) = (4, )

Light Robot BUILD Now, let us attack the Robot Light, the robot capable of orienting itself towards light whatever its origin. 2 Start by inserting the "Servo" into the "Footer" (). Take a helix in the shape of a cross and insert it on the other "Servo" (2). "S", "Short", indicates the short side, and "L" the side "Long". Snap it into the "Body Back". Insert the "T" of the foot into the slot provided for this purpose, and close the assembly by clipping the "Body Body Front" into the "Body Back". Finally, add the head to your robot. You can then hang the robot, the breadboard on its base and the UNO card on the cardholder. 3 You will now have to insert the photoresistors into the holes provided for this purpose and bring out their legs on the top of the robot head. Using the stabilizer, you can now connect the Uno card, the breadboard and the light robot to the same surface. You will need to use the cardholder and the boardholder to fit those two elements.

Light Robot BUILD Now let's take a look at the circuit of our model. On the left we find the 3 photoresistors connected to the head of our robot. These photoresistors have two pins, we plug 5V into one and one output into the other. Just as in the first model we set up a voltage divider to know the strength of the resistance and therefore the intensity of the brightness. 5V GND The stronger the brightness, the more the photoresistor will let the current flow. The voltage drop between point a and b will then be lower than between point b and c. A returning the voltage between point b and ground, A will be larger. Brightness Resistor Resistor 2 Total resistance (R+R2) A-B Voltage 5V *(R/(R+R2)) a b c A B-C Voltage 5V - T(a-b) Cas Forte 33 43,2 3,8 Cas 2 Faible 33 33 3,8,2 In the diagram, the three green wires represent this intermediate voltage. We connect them to the pins A, A and A2 to know their value (between and 23. The servo is connected to pin # 5.

Light Robot The objective of our robot light detector is to turn to the strongest light source nearby. For this, it has 3 photoresistors capable of analyzing the intensity of the light in the surroundings. We will therefore recover the intensity of the light (value between and 23) and deduce the angle to which the engine must place, thanks to some rules of trigonometry. In a first step, the sensors detect the brightness (). This system can be compared to a system of forces, or to a set of vectors (2). Thanks to this set of vectors, we can deduce the origin of the light source: Let us find the coordinates (x, y) of the resulting vector = Y = 2 cos 6 cos 6 2 X = sin 6 + sin 6 2 Length = X 2 + Y 2 To determine the angle, we could use the arccosine: Angle = cos (Length/Y) But this one would not give us the sign (+ or -) of the angle. We prefer the arc-tangeant: Angle = tan (x, y) We now have the angle in which our robot must go, but we need to take into account our robot s constraints: Our robot can move only from to 8 and its neutral position is at 9 and not at. We will therefore limit its movements and use the map() function to solve these constraints. _2_ TH3RY 2 2 - Detection of intensity 2- Analogy system of forces 3- Determination of the origin of light 2 2 2 θ 2-9 9 4- Adaptation to robot constraints 9 8

Light Robot #include <Servo.h> Servo servotronc; void setup() { servotronc.attach(5); pinmode(a,input); pinmode(a,input); pinmode(a2,input); Serial.begin(96); void loop() { int position = 9; servotronc.write(9); delay(2); int a = analogread(a); int b = analogread(a); int c = analogread(a2); _3_ CODE Let's now go to the programming of our robot. First we insert our servo library, the one we use since the beginning of our assemblies. We create a Servo object: 'servotronc' and then initialize the program with the setup() function where we say that a motor is attached to pin 5 and that the pins A to A2 will be information entries. We then run the loop() function. Inside it, we will indicate the starting position of the servo (9 ) and then read the data of the photoresistors: A b A a c A2 int y = b - cos(6*pi/8)*a - cos(6*pi/8)*c; int x = - sin(6*pi/8)*a + sin(6*pi/8)*c; float angle = atan2(x,y)* (8 / PI); int constrangle = ; if(angle< -9){constrAngle = -9; else if(angle> 9){constrAngle = 9; else {constrangle = angle;; constrangle = map(constrangle, -9,9,8,); Serial.print(a); Serial.print(" "); Serial.print(b); Serial.print(" "); Serial.print(c); Serial.print(" "); Serial.print(x); Serial.print(" "); Serial.print(y); Serial.print(" "); Serial.print(angle); Serial.print(" "); Serial.print(constrAngle); Serial.println(" "); servotronc.write(constrangle); delay(); From these values, we will calculate the origin of the strongest light, as explained on the previous page. The only difference is that we add (PI / 8), this ratio is added to transform the radians into degrees. Then we adapt our results to the constraints of the robot thanks to the map() function, as explained previously (4). To make sure we have good measurements, we print out our different results before asking our robot to move at the calculated angle.