Sunday, 24 November 2013

Ultrasonic Rangefinder Capability

Whilst setting up the "Sumo" ring, we had a few moments to think about where this all might go and what we might need from it in the future. Getting a sumo robot to detect an edge and to then turn away from it is an important step. Making the sumobot have ultrasonic functionality is the next step!
This is an ultrasonic rangefinder manufactureed by seeed electronics. In simple terms it sends out a sound wave and then measures the time it takes for the wave to return to the unit. Assuming that most returned sound waves "Bounce" off an object, with cunning programming you can make a robot sense distance.

This image shows the scale of the rangefinder. Note that the image shows two micro-controllers, in fact we will of course only use one. The fritzing diagram for connection to the Uno R3 and the SEN136B5B sensor is shown below...


Thursday, 14 November 2013

Flowcharting a Sumo Bot

Planning your code before you write it out is an essential part of writing efficient programs. Using a flow chart not only helps you think through what you want to achieve, but also allows you to share your thoughts with other people in a visual format. (It's not only computer programs that benefit from this - working out all sorts of processes can be easier using flow charts.)
We have a very effective method of producing and sharing flow charts available at CSC through Google Apps. It's called Lucidcharts and you can create a new chart easily using the Google drive interface...
 The software is very easy to use and is intuitive. This took me ten minutes to make. Part of the process involved dragging the boxes around on the page until I had them in an order that made sense to read through and follow. Here is a screenshot of how it looked before I exported it as a png...


Here is the finished flow chart. This is saved as an image file. If I wish to modify it in any way, I could always go back to the diagram on Lucidchart and make any changes that I want to. Saving files with sensible names and making allowance for future version changes also makes sense.

Wednesday, 13 November 2013

Border Detect Code

This is the basic code used to get the reflectance array to detect a border...
_____________________________________
#include <ZumoBuzzer.h>
#include <ZumoMotors.h>
#include <Pushbutton.h>
#include <QTRSensors.h>
#include <ZumoReflectanceSensorArray.h>

#define LED 13

// this might need to be tuned for different lighting conditions, surfaces, etc.
#define QTR_THRESHOLD  1500 // microseconds
 
// these might need to be tuned for different motor types
#define REVERSE_SPEED     200 // 0 is stopped, 400 is full speed
#define TURN_SPEED        200
#define FORWARD_SPEED     200
#define REVERSE_DURATION  200 // ms
#define TURN_DURATION     400 // ms

ZumoBuzzer buzzer;
ZumoMotors motors;
Pushbutton button(ZUMO_BUTTON); // pushbutton on pin 12

#define NUM_SENSORS 6
unsigned int sensor_values[NUM_SENSORS];

ZumoReflectanceSensorArray sensors(QTR_NO_EMITTER_PIN);

void waitForButtonAndCountDown()
{
  digitalWrite(LED, HIGH);
  button.waitForButton();
  digitalWrite(LED, LOW);
 
  // play audible countdown
  for (int i = 0; i < 3; i++)
  {
    delay(1000);
    buzzer.playNote(NOTE_G(3), 200, 15);
  }
  delay(1000);
  buzzer.playNote(NOTE_G(4), 500, 15);
  delay(1000);
}

void setup()
{
  // uncomment if necessary to correct motor directions
  //motors.flipLeftMotor(true);
  //motors.flipRightMotor(true);
 
  pinMode(LED, HIGH);
 
  waitForButtonAndCountDown();
}

void loop()
{
  if (button.isPressed())
  {
    // if button is pressed, stop and wait for another press to go again
    motors.setSpeeds(0, 0);
    button.waitForRelease();
    waitForButtonAndCountDown();
  }
 

  sensors.read(sensor_values);
 
  if (sensor_values[0] < QTR_THRESHOLD)
  {
    // if leftmost sensor detects line, reverse and turn to the right
    motors.setSpeeds(-REVERSE_SPEED, -REVERSE_SPEED);
    delay(200);
    motors.setSpeeds(TURN_SPEED, -TURN_SPEED);
    delay(300);
    motors.setSpeeds(FORWARD_SPEED, FORWARD_SPEED);
  }
  else if (sensor_values[5] < QTR_THRESHOLD)
  {
    // if rightmost sensor detects line, reverse and turn to the left
    motors.setSpeeds(-REVERSE_SPEED, -REVERSE_SPEED);
    delay(200);
    motors.setSpeeds(-TURN_SPEED, TURN_SPEED);
    delay(300);
    motors.setSpeeds(FORWARD_SPEED, FORWARD_SPEED);
  }
  else
  {
    // otherwise, go straight
    motors.setSpeeds(FORWARD_SPEED, FORWARD_SPEED);
  }
}

Sumo - watch out for the edge......


 The first test of the prototype of the Zumo bot arena






Anyone for a fight?

We've talked about sumo for a while now. It's been one of our goals to get some sumo up and running.
The way we see it, we need to do it in three stages:

  1. Get a Zumo chassis up to an operational stage.
  2. Program a Zumo chassis to detect an edge, reverse from it, turn around and run across the sumo ring.
  3. Be a bit more clever and get a Zumo to detect another robot (maybe using an ultrasonic rangefinder) and push it out of the ring.
We have started to make a sumo ring... This will be finished in a couple of days!

Zumo Reflectance Array

Proud photos of the reflectance array. This took a little bit of sorting our to get it working correctly. But we got there in the end. The first time that we got it to work was just amazing! We all stood round it and watched it follow a line of black masking tape around a table in the graphics room.
Here a are a few photos to explain some of it to you...

 The reflectance array consists of six sensors, each consisting of an IR emitter coupled with a phototransistor that responds based on how much emitter light is reflected back to it. The two outside sensors are positioned at the very edges of the module to maximize their usefulness as edge detectors (e.g. for seeing the white edge of a sumo ring) while the four inner sensors are closer together for better detecting lines.
The Zumo Bot chassis with the Arduino R3 mounted on top of it upside down.

The two outside sensors emitting IR. The array is mounted on the leading edge of the bot chassis, just behind the blade. This photo shows the bot positioned upright, balancing on its back.

A closer photo of the array

Sunday, 20 October 2013

Dim & Dimmer


When I started to make this project I only had a few components at my disposal, two Potentiometer's, a single LED and some miscellaneous resistors. At first I used the example sketch AnalogReadSerial to print the value of a Potentiometer to a serial monitoring program on my PC. After seeing the Fade sketch that allows a LED to fade in and out. I got ideas from both pieces of code and then managed to write a compact and simple sketch allowing the brightness of an LED to be controlled by a Potentiometer.

// If any of the images are too small click once to enlarge.
// Sorry about the video quality, it was compressed to lower resolution after being uploaded.

Code:

Circuit Diagram:
Demonstration:

Saturday, 12 October 2013

Arduino ISP(In System Programming)


Using arduino isp you can program a AVR. Avr is the heart of arduino, the arduino uno has a ATmega328p( the "p" stands for  pico power, less power and more effiency.) If you go ahead and open the arduino isp form file-->examples-->arduino isp.
If you scroll down you can see the pin configuration on your arduino and the Avr( note that your AVR pin configuration can differ). 

First you have to power the AVR using 5V and GND. the you have to connect the actual communication pins. MOSI( MASTER OUT SLAVE IN), MISO( MASTER IN SLAVE OUT), SCK(THE CLOCK) AND THE RESET. and you have to put 10uf capacitor to diasable auto reset.  Then Google "winavr" and install it.




Here is the AVR led blink. open and write this into programmers notepad. THIS PICTURE IS NOT MINE!!!










/***********************************************************************
make sure to attach a LED to + to PB0 and - to GND.
written and created by randipa. project 1.2

*************************************************************************/
#define F_CPU=8000000; // setting the cpu clock make sure to divide the crystal oscilator by 8;
#include <util/delay.h> // including the delay header
#include <avr/io.h> // including iostream to avr


int main(){
DDRB = 0xff; // data direction port b. using hex. 0xff= 0b11111111 setting all of it to output.
PORTB = 0; // setting port b to 0V.


  While(1){

      PORTB = 0;
      _delay_ms(100) // delay 100ms
      PORTB = 0xff;
      _delay_ms(100)  //if your are too lazy type PORTB^=0xff; _delay_ms(100);  this will xor which will invert.

 }
 retun 0;
}

save this in the c directory.
Goto CMD and "cd .." press enter "cd .." press enter again. And type "avrdude -c avrisp -p m328p -U flash:w:ledblink.hex"
(without any quotes) make sure use -p to your avr part.

Bootloader?

You might be wandering if you can program avr and arduino in one language. yes You can avr and arduino has a different language because of the bootloader. bootloader is a firmware(you can only write.) Bootloader is the piece of code which runs when the power was supplied. the bootloader recognise the code and do everything else. if you want to do this search google " bootloader avr arduino" Only do this if you know what you are doing(I tried this and bricked my ATmega8)

13107@csc.school.nz
11127@csc.school.nz

Friday, 11 October 2013

Let there be ... Lights? (From Freetronics Project Guide Book)

Here is a sketch that makes a light "scan" along a row of LEDs, very similar to the Kitt scanner in the show Knight Rider or the red Cyclon eye in Battlestar Galaticica.

Here is the sketch:


It is basically the beginner's sketch "Blink", but with  8 LEDs.


// Project II, Controlling 8 LEDs

int ledCount = 8;
int ledPins [] = { 6, 7, 8, 9,  10,  11, 12, 13};
int ledDelay = 100
;

// the setup routine runs once when you press reset:
void setup() {                
 for (int thisLed = 0; thisLed < ledCount; thisLed++) {
   pinMode (ledPins[thisLed], OUTPUT);
 }
}

   
   void loop () {
    for (int thisLed = 0; thisLed < ledCount; thisLed++) {
      digitalWrite (ledPins [thisLed], HIGH) ;
      delay(ledDelay);
      digitalWrite (ledPins [thisLed], LOW) ;
    }
    for (int thisLed = ledCount-1; thisLed > 0; thisLed--)  {
      digitalWrite (ledPins[thisLed], HIGH) ;
      delay(ledDelay);
      digitalWrite (ledPins [thisLed], LOW) ;
      }
    }

In this code, instead of writing the instructions for each LED, we use a 'For' loop, which runs pinMode( ) eight times but with a different value each time.  

The Next part tells the Arduino when to stop the 'For' loop.  This will keep repeating until the conditions are not met, so for this example until the value of 'ledPin' is greater than the value of 'ledCount', so in this case 'ledCount' is 8 so it will keep going up until until ledPin reaches 8.  

The last part is an action that the loop will do each time it runs.  The '++' is a shorthand or quicker way to take a variable (in this case thisLed) and add one to it each time.  


Once the first loop finishes, (in this case thisLed reaches the same value ledCount), the second loop begins.  The second loop is almost identical to the first, but it goes backwards, it starts at the value of 'thisLed' and each time it runs through, it uses the '--' action to decrease the the value of the position by one each time.  

When it reaches the start of the list, the second loop finishes and the program jumps back to the first loop to do it all again.   


Thanks for Reading,

Logan Cox

12044@csc.school.nz or
loggie374@gmail.com  

Tuesday, 8 October 2013

Flow Charts to help work out your sketch...

We have unlocked LucidChart on CSC Google Apps Domain. This means that you can now create a LucidChart diagram as an option through Google Drive. This is possible through your school Google Apps account.
Flow charts are an excellent way to iron out the different stages that you would like in your program or "Sketch" in Arduino. Flow charting your sketch also helps you to communicate the purpose of your sketch to other people.
Here is an example of a very simple flow chart, created using LucidChart...

Friday, 4 October 2013

Program Structure - Functions

When writing code there are almost always several ways to do things, but one thing that most programmers try to achieve is to get their code compact and to use as little space as they can.
This code is available on our File Cabinet page, or through a direct link here...

All of the comments to explain the code are in the sketch and follow these signs //
This mean that the Arduino does not read anything after the two symbols:
// The arduino recognises this as a comment.

It is very simple to set up...
This diagram was produced using Fritzing. A link to a download for Fritzing is available on our File Cabinet page. Note that the positive power rail at the bottom is not needed, but it is good practise to include it in case your project develops and needs use of it.

Here  is the sketch...
___________________________________________________
/*
This Sketch shows two useful concepts in writing sketches for Arduino.
Firstly it demonstrates how to use FUNCTIONS and then call them in the sketch.
It also demonstrates how to use a WHILE loop, using a count to add to a
predefined variable
 */

// Give Pin 13 a name...
int led = 13;
int count = 0;

// the setup routine runs once only, when you press reset:
void setup() {              
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);    
}

// the loop routine runs over and over again forever:
void loop() {
  Reset();        // Call the "Reset" function declared at the bottom of this sketch
  SlowBLINK();    // Call the "SlowBLINK" function declared at the bottom of this sketch
  Reset();
  MediumBLINK();  // Call the "MediumBLINK" function declared at the bottom of this sketch
  Reset();
  FastBLINK();    // Call the "FastBLINK" function declared at the bottom of this sketch

}

void SlowBLINK()    // Funtion named "SlowBlink"
{
while(count < 5)             // Repeat whilst the value of "count" is less than 5
  {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
count++;                     // add "1" to the value of "count"
  }
}
void MediumBLINK()    // Funtion named "MediumBlink"
{
while(count < 10)            // Repeat whilst the value of "count" is less than 10
  {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);                // wait for 500ms
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(500);                // wait for 500ms
count++;                     // add "1" to the value of "count"
  }
}
void FastBLINK()    // Funtion named "FastBlink"
{
while(count < 50)            // Repeat whilst the value of "count" is less than 10
  {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                // wait for 100ms
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(100);                // wait for 100ms
count++;                     // add "1" to the value of "count"
  }
}
void Reset()        // Funtion named "Reset"
  {
  count = 0;                 // Reset the value of the variable "count" to "0"
                             // this needs to be done to make the "while" functions work.
  }



Thursday, 3 October 2013

A New Look for Arduino "CC"

It's good to see some of you posting on our blog, great links from Brodie, and some good work by Janitha and Randipa on controlling an LED using their Arduino.

Whilst looking at some of Brodie's links, I noticed that the Arduino Creative Cloud Web Site has a new look to it. It's well worth a look...
http://www.arduino.cc

Don't forget that you all have (Or can request) permissions to be able to save links to our FILE CABINET on our CSC Arduino Development Group Web Site. We can then keep all manner of files and links that you submit together in one place.

Sunday, 29 September 2013

LED Blink


This is our first project with Arduino. We made a LED blink to the command of a switch.

These are series of images of the Arduino in action ( the video took too long to upload). We programmed the board to read the state of the switch and blink the LED on pin 13 if the reading is HIGH and turn the LED off If the Reading is LOW. We also programmed the board to read the state of the switch and blink 3 LEDs in to a pattern if the state of the switch is HIGH and turn the LEDs off if the state of the switch is LOW. The sketch and the schematic (the circuit diagram) for this will be available in the file cabinet.

Reading the switch to blink the LED.
                                                           
When the state of the Switch is LOW don't blink the LED on pin 13.











When the state of the Switch is HIGH blink the LED on pin 13.







Blinking LED on pin 13.











Random Blinking when the state of the switch is HIGH.


When the state of the switch is LOW don"t blink the LEDs.




When the state of the switch is HIGH blink the LEDs in to a pattern.










Janitha and Randipa Gunathilake.
11127@csc.school.nz
13107@csc.school.nz

Saturday, 28 September 2013

Links and So Forth



My first post on the CSC Arduino Development Group Blog, Just thought I would share some links and resources I have found useful.

Arduino Creative Cloud
arduino.cc
This site is own and operated by the very people that bought you the actual Arduino boards, however almost all the content is submitted by end-users.

Element 14 Community
element14.com/community
Element 14 is a store for electronics hobbyists and trades people. You can buy everything from resistors to arc welders. There community is great, its run by hundreds of dedicated engineers that answer every question you can throw at them.

Jeremy Blum
jeremyblum.com
youtube.com/channel/UC4KXPjmKwPutGjwFZsEXB5g
Jeremy Blum is one of the leading authorities on Arduino. He has a personal website, YouTube channel, and Page on the Element 14 Community. His video tutorials are extremely helpful.

Make
makezine.com
youtube.com/channel/UChtY6O8Ahw2cz05PS2GhUbg
Make is primarily a magazine, But their YouTube channel and website are very good. They have lots of projects ranging from electronics to automotive modifications (everything encompassing make or making). Although their tutorials are very brief (not a lot of details) they are a great source of ideas.

EEV Blog
eevblog.com/
youtube.com/channel/UC2DjFE7Xf11URZqWBigcVOO
Austrailian electrician David L. Jones plays with and explains electronics in his informative if somewhat lengthy videos. Not a huge amount of Arduino content as such, but a lot about circuit boards and prototyping (huge part of Arduino).





Brodie McGlen

bwmcglen@gmail.com
12027@csc.school.nz

Friday, 27 September 2013

The Launch of our Group

Friday 28th of September saw a group of around ten interested students meet up together in the technology Department.
We had a look at what we could do with an Arduino Board and invited students to look into it for themselves and then decide whether they would like to become part of the group. All in all, it was a very exciting start, particularly for Mr Maher and myself who were delighted to see so much interest in our small but select group!
Brodie McGlen and Logan Cox requested to become authors of this blog, which will allow them to make posts of their experiences.
Mr Jag.

Wednesday, 25 September 2013

Zumo Bot's First instructions

This is a short video of Zumo Bot performing a task.
Zumo Bot is a hardware system belonging to the Technology Department's Arduino Development Group.
Every action that the robot takes has been programmed. Each motor has been told when to activate, for how long, at which speed and in which direction. By making both motors work at the same time in opposite directions, the robot can turn quickly.



Tuesday, 24 September 2013

The Zumo has life...

A quick photo of our zumo chassis complete with sheild. The blade at the front is for moving objects.

Thursday, 15 August 2013

New Hardware

We've added a few more hardware items to our borrowing library. An mp3 shield and a temperature sensor should provide a few interesting design options. See our hardware page for a better view and description of these items.

Thursday, 11 July 2013

Hardware for student use

Some of the hardware components that we have available for use. More information on each one is available on our hardware page. If you would like to borrow one, have a look at our Borrowing page.

Zumo Robot Kit for Arduino (No Motors)
A Zumo Robot kit - this might lead to "Robot Wars"?

Ethernet Shield - W5100
An Ethernet Shield - control your Arduino from a web page

LCD Shield For Arduino
An LCD Shield - make your Arduino have a "Menu" or make text visible.

Arduino Wi-Fi Shield
A Wi-fi Shield - communicate with your Arduino wirelessly - perhaps even through Android?

Welcome

Welcome to the CSC Technology Arduino Blog.

If you have found your way here, chances are that you are interested in Technology and in computers and micro-processors.

We aim to form a group of people who learn together and who support each other in the development of technologically advanced products.

To follow the progress of our group is of course free, but if you wish to become active within our group and borrow some of our shields or components, you must have your own Arduino Board and be able to prove to us that you are able to at least get started with it on your own. This will hopefully ensure that you understand that this is an intellectually challenging undertaking, not simply plugging together kids' robot components!

Owning your own Arduino before you borrow our components will help you to understand that
the hardware that we are able to share with students is delicate, fragile and needs to be treated with a certain sympathy and understanding.

We suggest the Arduino Uno R3 available through www.mindkits.co.nz available by clicking the image below.



We want students to be able to contribute and post to this blog, so if you are serious about joining us on a technologically challenging journey, let us know!