Filters
Close
RSS

Blog posts tagged with 'Frobo V3 part 1'

Frobo V2 Programming Lesson -Part 1

Welcome to the Arduino programming lesson part 1. 

What is arduino?

Arduino is an open source electronics programming software and harware. You can use Arduino to read sensor input like a switch, echo of sound, light relections and millions of other inputs and create commands to control motors, lights and other actuators. Arduino is simply the most popular robotic learning platform for students, hobbyists and professionals. This being an open source platform, a vast amount of information is easily available to develop thousands of projects.

Learn more about Arduino

What is Froboduino?

Froboduino is an initiative by Hobbyandyou.com team to take this movement forward to teach children this the fundamentals of electricity an electronics. We will guide you through thse easy to undersatnd lessons in several parts. We are sure that after the completion of Frobo module V4, you will be in position to develop your own applications of increasing complexities. We have created our own development board called froboduino with a motor driver and a two channel Op-Amp LM358 to enable children to develop not only Frobo module but also a lot of other useful projects. Froboduino can be programmed with Arduino uno or any FTDI programmer. Separate programming ports are provided for easy to use programming.

How to get started?

You will need a laptop or a desktop to get started learning this. You can do with any laptop with windows, MAC or LNUX based operating systems. Arduino has a lot of older versions available for different generations of systems.

You need to download right version of Arduino IDE (Integrated development environment) from the link below.

Arduino IDE download

After downloading the IDE, install the IDE by following instructions. You can find detailed instructions here.

Your Frobo V3 kit includes a separate Arduino Uno as a programmer and also as your indenpendent programming board for other applications. On the Froboduino board there is 4 Pin programming port marked as PR. The port 1 of PR goes to RSET. We need to connect RSET to the next 5V port. There is two pin jumper in te kit. Connect RSET and 5V with the jumper. Connect PIN2 of PR to Rx piun on Uno and Pin3 to Tx pin of arduino. Connect Uno to your compuer with the USB cable. Take two red Leds from the kit and connect Red wire to L1 port +ve and Green wire to L1 port -ve, similarly, connect the other Led to L2 +ve and -ve ports.

This Arduino Uno comes with a USB 2.0 Male tyeA to Male type B  perpheral cable. Connect USB to your compuer USB port and the other male B type to your Uno. Click open Arduino IDE and from top menu select "Tools > Boards> Arduino Nano

Arduino>Tools.Boards>Arduino Nano

Now, select "Tools>Ports> right port  (Usually COM3, COM5 etc on windows). (See picture below)

Arduino>tools>ports

After you have succesfully set up your arduino IDE. It is now time for your first program on Froboduino. We will first begin with connecting motors and controlling motion with two geared motors provided with Frobo kit. Connect +ve terminal of left Motor to M1+ and - ve terminal to M1-. Similarly connect right Motor to M2 +ve and -ve ports on Froboduino. Let us look at the motor controlling code.

 

// Connect left motor +ve terminal to M1+ and -ve to M1- ports and similarly connect M2.

// Declare constants.

#include <Servo.h>

//declare servo as object.

Servo steeringServo;

 

// accelerator is used to control Frobo speed. Remember PWM!

const int accelerator = 5;

//Moves left motor in forward direction.

const int leftMotorFwd = A0;

// Moves left motor is backward direction.

const int leftMotorRev = A1;

//Moves right motor in forward direction.

const int rightMotorFwd = A2;

// Moves right motor in backward direction.

const int rightMotorRev = A3;

 

//We need not define pinMode as all pins are taken as INPUT by default. Setup code runs only once when program starts.

 

void setup()

 

{

// Define LEDs and Motors as outputs. Inputs are defined by default.

 

pinMode(accelerator, OUTPUT);

pinMode(leftMotorFwd, OUTPUT);

pinMode(leftMotorRev, OUTPUT);

pinMode(rightMotorFwd, OUTPUT);

pinMode(rightMotorRev, OUTPUT);

// Let us open the serial ports with data rate 9600 bits /second

steeringServo.attach(6);

Serial.begin(9600);

//Declare starting position. Use this to set your wheel.

steeringServo.write(90);

}

 

//This loop code runs repeatedly

 

void loop()

 

{

//This is the basic froboduino code for controlling motors to move in different directions.

//This code will move Frobo forwards for 5 seconds.

// accelerator powers the motors, so any movement, we have to set it "High".

Serial.println("Frobo will move forward for 5 seconds");

digitalWrite (accelerator, HIGH);

digitalWrite(leftMotorFwd, HIGH);

digitalWrite (leftMotorRev, LOW);

digitalWrite(rightMotorFwd, HIGH);

digitalWrite (rightMotorRev, LOW);

// Let this motion continue for 5 seconds (5000 mili seconds).

delay(5000);

// This code will now turn frobo left for 3 seconds and will move it forward for 5 seconds.

// by stopping left motor and running right motor, we will move Frobo in left direction.

Serial.println("Now Frobo will turn left");

digitalWrite(leftMotorFwd, LOW);

digitalWrite (leftMotorRev, LOW);

digitalWrite(rightMotorFwd, HIGH);

digitalWrite (rightMotorRev, LOW);

delay(3000);

Serial.println("Then Frobo will move forward for 5 seconds");

digitalWrite(leftMotorFwd, HIGH);

digitalWrite (leftMotorRev, LOW);

digitalWrite(rightMotorFwd, HIGH);

digitalWrite (rightMotorRev, LOW);

delay(5000);

digitalWrite(leftMotorFwd, LOW);

digitalWrite (leftMotorRev, LOW);

digitalWrite(rightMotorFwd, LOW);

digitalWrite (rightMotorRev, LOW);

delay(1000);

//This code will Frobo backwards for 5 seconds.

Serial.println("Now Frobo will move backward for 5 seconds");

//digitalWrite(accelerator, HIGH);

digitalWrite(leftMotorFwd, LOW);

digitalWrite (leftMotorRev, HIGH);

digitalWrite(rightMotorFwd, LOW);

digitalWrite (rightMotorRev, HIGH);

delay(5000);

//This code will turn frobo in right direction for 3 seconds in backward motion.

Serial.println("Now Frobo will turn right in backward motion");

digitalWrite(leftMotorFwd, LOW);

digitalWrite (leftMotorRev, HIGH);

digitalWrite(rightMotorFwd, LOW);

digitalWrite (rightMotorRev, LOW);

delay(3000);

// This code will stopFrobo for 5 seconds.

digitalWrite(leftMotorFwd, LOW);

digitalWrite (leftMotorRev, LOW);

digitalWrite(rightMotorFwd, LOW);

digitalWrite (rightMotorRev, LOW);

delay(5000);

digitalWrite(leftMotorFwd, HIGH);

digitalWrite (leftMotorRev, LOW);

digitalWrite(rightMotorFwd, HIGH);

digitalWrite (rightMotorRev, LOW);

delay(5000);

//Imagine controlling motion to create dance effects. Try moving from forward for 1 second and then turn left for a second and turn right for a second and make it move backwards for 4 seconds. This is an exercise for you.

}

Here is the Video for your reference...

How did you like your your first lesson in Frobduino/Arduino? This is just the beginning of an exciting series of robotic lessons. In the subsequent parts, we will learn about other output devices and sensor data reading.