Showing posts with label Arduino Technology. Show all posts
Showing posts with label Arduino Technology. Show all posts

Thursday, May 31, 2012

LCD Keypad Shield for Arduino Duemilanove, DealExtreme

If you have ordered "LCD Keypad Shield for Arduino Duemilanove & LCD 1602" from DealExtreme and are wondering about how to get this thing working without datasheet, you are in the right place :-) This product seems to be very similar(!) a product called "DFRobot LCD Keypad Shield for Arduino" and the Datasheet and even a library (LCD4bit_mod) for easy programming of it is available at following link, http://www.robotshop.com/dfrobot-lcd-keypad-shield-arduino.html, under useful links.

 The only issue with the library is that this is built for old versions of Arduino and if one to make it work with newest version (Arduino 1.0), then some parts of the code should change. First you need to install the additional library in your Arduino on your computer ( tutorial on how to install). Afterwards one should change the content of LCD4bit_mod.cpp 


#include "LCD4Bit_mod.h"
#if (ARDUINO < 100)
  extern "C" {
    #include   //not needed yet
    #include //needed for strlen()
    #include
    #include "WProgram.h"
  }
#else
  #include
#endif

Sunday, May 20, 2012

Flame Detector Sensor, Arduino Tutorial


This is a sample code to show how this cheap component from DealExtreme works with Ardunio (2.5$ with free shipping). These are very useful sensors for building [b]firefighting robots[/b]  :D  Look at the sample code for more info.
Sensor detecting match flame


purchase link:
http://www.dealextreme.com/p/arduino-flame-sensor-for-temperature-detection-blue-dc-3-3-5v-118075

OBS1: I assume this component uses Infrared and should be in direct sight to detect flame. This would work easily on big flames but for a match flame (very small), it could miss it.
OBS2: I read the values with analogRead but I guess they are readable with Digital Read as well as differences are quite high.
-------------------------
/*
  FLAME detector connected to Arduino
  http://www.dealextreme.com/p/arduino-flame-sensor-for-temperature-detection-blue-dc-3-3-5v-118075

 Developer:
 Akbar (Shahab) F. Moghaddam
 20.05.12

 Comment : I assume this component uses Infrared and should be in direct sight to detect flame. This would work easily on big flames but for a match flame (very small), it could miss it.

 */

//CONSTANTS
const int pinD0 = 0;
const int pinA0 = 1;

//VARIABLE
int A = -999;
int D = -999;
int readVal = 0;
boolean logging = false;
boolean fire = false;
boolean changed = true;


void setup() {              
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);
  pinMode(0, INPUT);
  pinMode(1, INPUT);
  Serial.begin(19200);
}

void loop() {
  initialAll();
  readValues();
  loggingProcess();
  if (changed)
    printState();
  delay(1000);// wait for a second
}

void initialAll(){
  readVal = 0;
}

void readValues(){
  A = analogRead(pinA0);
  D = analogRead(pinD0);
  fireCheck();
  if (Serial.available()>0){
    readVal = Serial.read();
  }
}

void loggingProcess(){
  if (readVal == 'l'){
    if (logging)
      logging = false;
    else
      logging = true;
  }
 
  if (logging){
    Serial.println("------------");
    Serial.println("SYUMMARY");
    Serial.print("A0:");
    Serial.println(A);
    Serial.print("D0:");
    Serial.println(D);
    Serial.println("------------");
  }
}

void printState(){
  if (fire){
    Serial.println("------------");
    Serial.println("FLAME Detected");
    Serial.println("------------");  
  }
  else{
    Serial.println("------------");
    Serial.println("NO FLAME");
    Serial.println("------------");  
  }
  changed = !changed;
}

void fireCheck(){
  if (A < 350 && D < 350){
    fire = true;
    changed = !changed;
  }
  else{
    fire = false;
    changed = !changed;  
  }
}

Quality Joystick from DealExtreme (very cheap)


Here I am about to write a tutorial about a cheap joystick I came across lately which can be bought for only 3.5$ with free shipping to Norway. It is a PS2 repair kit which can easily be used with Arduino concept as well (the input voltage is 5+). It can detect all 8 directions in 2D dimension and also Clicked feature.

Joystick tutorial

Purchase link:
http://www.dealextreme.com/p/repair-parts-replacement-analog-stick-module-for-ps2-controller-black-121340

Here the outputs from the joystick are only VRx, VRy, SW, GND and +5V.
VRx = x value (see program)
VRy = y value (see program)
SW = if Clicked or Not -> Clicked = 0, NOT clicked = 1

-----------------------

/*
  JOYSTICK Program connected to Arduino
 http://www.dealextreme.com/p/repair-parts-replacement-analog-stick-module-for-ps2-controller-black-121340

 Developer:
 Akbar (Shahab) F. Moghaddam
 20.05.12

 Comment : Front, Back, left, right
 */

//CONSTANTS
const int pinX = 2;
const int pinY = 1;
const int pinSW = 0;

//VARIABLE
int VRx = -999;
int VRy = -999;
int SW = -999;
int readVal = 0;
boolean logging = false;


void setup() {              
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);
  pinMode(0, INPUT);
  pinMode(1, INPUT);
  pinMode(2, INPUT);
  Serial.begin(19200);
}

void loop() {
  initialAll();
  readValues();
  loggingProcess();
  printState();
  delay(1000);// wait for a second
}

void initialAll(){
  readVal = 0;
}

void readValues(){
  VRx = analogRead(pinX);
  VRy = analogRead(pinY);
  SW = analogRead(pinSW);
  if (Serial.available()>0){
    readVal = Serial.read();
  }
}

void loggingProcess(){
  if (readVal == 'l'){
    if (logging)
      logging = false;
    else
      logging = true;
  }

  if (logging){
    Serial.println("------------");
    Serial.println("SYUMMARY");
    Serial.print("X:");
    Serial.println(VRx);
    Serial.print("Y:");
    Serial.println(VRy);
    Serial.print("SW is:");
    Serial.println(SW);    
    Serial.println("------------");
  }
}

void printState(){
  if (SW == 0){
    Serial.println("------------");
    Serial.println("CLICKED");
    Serial.println("------------");  
  }
  else if (VRx > 330 && VRx < 350 && VRy > 325 && VRy < 350){
    Serial.println("------------");
    Serial.println("NORMAL");
    Serial.println("------------");  
  }//NORMAL
  else if (VRx > 660 && VRx < 700 && VRy > 325 && VRy < 350){
    Serial.println("------------");
    Serial.println("FRONT");
    Serial.println("------------");
  }//FRONT
  else if (VRx < 5/*==0*/ && VRy > 325 && VRy < 350){
    Serial.println("------------");
    Serial.println("BACK");
    Serial.println("------------");
  }//BACK
  else if (VRx > 330 && VRx < 350 && VRy < 5 /*==0*/){
    Serial.println("------------");
    Serial.println("LEFT");
    Serial.println("------------");  
  }//LEFT
  else if (VRx > 330 && VRx < 350 && VRy > 665 && VRy < 700){
    Serial.println("------------");
    Serial.println("RIGHT");
    Serial.println("------------");  
  }//RIGHT
  else if (VRx > 350 && VRx < 680 && VRy > 350 && VRy < 670){
    Serial.println("------------");
    Serial.println("FRONT-RIGHT");
    Serial.println("------------");  
  }//FRONT-RIGHT
  else if (VRx >= 0 && VRx < 350 && VRy > 350 && VRy < 680){
    Serial.println("------------");
    Serial.println("BACK-RIGHT");
    Serial.println("------------");  
  }//BACK-RIGHT
  else if (VRx >= 0 && VRx < 330 && VRy >= 0 && VRy < 325){
    Serial.println("------------");
    Serial.println("BACK-LEFT");
    Serial.println("------------");  
  }//BACK-LEFT
  else if (VRx > 350 && VRx < 680 && VRy >= 0 && VRy < 325){
    Serial.println("------------");
    Serial.println("FRONT-LEFT");
    Serial.println("------------");  
  }//FRONT-LEFT
  else{
    Serial.println("------------");
    Serial.println("UNKNOWN");
    Serial.println("------------");  
  }//UNKNOWN
}

Tuesday, May 1, 2012

Arduino Mega 2560 driver could not be found on Windows 7

Issue: Arduino Mega 2560 driver could not be found on Windows 7
Solution: Simply go to Start - right click on Computer - Properties - Device Manager -  Under Other Devices, Find Arduino Mega 256 - right click and choose update driver - Choose Browse computer for driver software - Click Browse and Navigate to your Arduino home folder(where you installed Arduino) and choose drivers folder and  click Next. The windows 7 would find the right driver inside the folder.

Happy coding with Arduino :-)

Wednesday, February 22, 2012

3pi robot LCD from Arduino


What is a 3pi robot ?
What is an Arduino board ?

----------------

#include

OrangutanLCD lcd;

void setup()               // run once, when the sketch starts
{

}

void loop()                // run over and over again
{
  // avoid clearing the LCD to reduce flicker
  lcd.gotoXY(0, 0);
  lcd.print("Line 1");
  lcd.print("  ");              // overwrite any left over digits
 
  lcd.gotoXY(0, 1);

  lcd.print("Line 2");
  lcd.print("  ");              // overwrite any left over digits

}

3pi motor control from Arduino

What is a 3pi robot ?
What is an Arduino board ?
What is an AVR Atmel Micro-controller ?
----------------
#include

OrangutanMotors motors;

void setup()               // run once, when the sketch starts
{

}

void loop()                // run over and over again
{
  // note that the following line could also be accomplished with:
  // int pot = analog.read(7);
  //int pot = analog.readTrimpot();    // determine the trimpot position
  int motorSpeed1 = 25;  // turn pot reading into number between -256 and 255
  int motorSpeed2 = 0;  // turn pot reading into number between -256 and 255

// Minus - Zero -> back to right (turn around one point)
// Zero - Minus -> Back to leftt (turn around one point)
// Positive - Zero -> front to right (turn around one point)
// Zero - Positive -> front to left (turn around one point)

// Speed1 < Speed2 -> back to right
// Speed1 > Speed2 -> Back to leftt
// Speed1 > Speed2 -> front to right
// Speed1 < Speed2 -> front to left
// looking at robot from back ->  left number goes to left motor & right goes to right motor
motors.setSpeeds(motorSpeed1,motorSpeed2);
}
---------------

Friday, May 6, 2011

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51 Error on Arduino IDE

If you are receiving the following error from Arduino :

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

Double check if you have the right Arduino board selected. The most common cause of this error (IMO) used to be people choosing the Duemilanove 128 when they had the newer Duemilanove 328.  Click on Tools - Board and make sure you have the right board chosen, and try again.

Tuesday, January 11, 2011

A red bleeding edge artifact

I liked this one ;-) very cool :-D Soooooo bleeding edge, we HAD to maked it RED ;-)

Friday, January 7, 2011

RxTx API, Java

By clicking on the following link you can have access to the full directory of RxTx library API's in Java :

Tuesday, December 14, 2010

RepRap project, the beginning of an adventure …

The RepRap project; an open source 3D printer, with all the technologies including inside it is a magnificent piece of technology to learn and study deeply. A combination of chemistry, physics, computer science, robotic technology and etc. Something that is produced by prosumers for prosumers(or even consumers as you don’t have to develop it further). A good that belongs to the non-rival(or even anti-rival), non extendable part of the production world. A product of CBPP in the public domain which in 5 years since Adrian came up with the idea, has managed to build a strong community in many different countries all around the world, dedicated developers around it and last but not least three functioning versions of 3D printers. I am honored to say that I am leading this project at Robotica Osloensis. Our first objective is to study and learn the RepRap concept and later take part in the development of this artifact. More updates on this project later.

Sunday, October 24, 2010

want Arduino to wait for a special input ?

x=0
while (x==0) {
x=digitalRead(some pin)
}

RepRap

I am currently writing a report about RepRap at a course I take at university of Oslo(IFI), called INF5078(Open source, open collaboration and innovation). I will post my report here later.

What is RepRap ?
Knock yourself out : http://reprap.org/wiki/Main_Page & maybe even join :-)

Monday, May 24, 2010

Super Crawler

Super Crawler was our summer project to build a robot in summer 2009. The project was delayed according to practical problems we faced. It is still an on going project and is schelued to be finished by the end of summer 2010. The new team which works on the project is 2 of us from summer 2009 plus a new fresh team from Robotica Osloensis student robotic community.
You can learn more about Super Crawler by clicking here.