Floating Ball With Arduino

Ok, I’m working in something interesting…

IMG_0002

All the hardware is working.

togrther

 

Software routines to control the FAN (PWM) and reading the IR Range Sensor GP2D120 (from SHARP) also working….

GP2D120_ref

Now, the problem… closing the loop…. :)

 

Categories: Uncategorized

Stellaris LaunchPad and Energia

Here is the Stellaris LM4F120 LaunchPad from Texas Instruments.

StellarisLP_06
This is a test of the ARM based development board using  Energia (Arduino-Like development environment).
The Blink example of the Arduino IDE was adapted to blink the RGB LED in the Stellaris:
RGB= RED-GREEN-BLUE

The code used (the sketch):

/* Blink3LEDS.ino
  Arduining.com / DIC 2012
  Sketch to turn on the LEDs of The Stellaris LaunchPad in sequence.
  Each led (RED, GREEN and BLUE) are turned on for one second and then off for
  another second repeatedly.
 */

void setup() {                
  // initialize the pins as digital outputs.
  pinMode(RED_LED, OUTPUT); 
  pinMode(GREEN_LED, OUTPUT); 
  pinMode(BLUE_LED, OUTPUT);
  
}

void loop() {
  digitalWrite(RED_LED, HIGH);    // set the Red LED on
  delay(1000);                    // wait a second
  digitalWrite(RED_LED, LOW);     // set the Red LED off
  delay(1000);                    // wait a second
  
  digitalWrite(GREEN_LED, HIGH);  // set the Green LED on
  delay(1000);                    // wait a second
  digitalWrite(GREEN_LED, LOW);   // set the Green LED off
  delay(1000);                    // wait a second
  
  digitalWrite(BLUE_LED, HIGH);   // set the Blue LED on
  delay(1000);                    // wait a second
  digitalWrite(BLUE_LED, LOW);    // set the Blue LED off
  delay(1000);                    // wait a second
}

See the Video on YouTube:

Categories: Uncategorized

Arduino PWM and Mini Motor

April 8, 2013 Leave a comment

Driving a vibrating motor directly from an Arduino is possible without burning it.

Using a 75 Ohms series resistor the current can be maintained under 40 milliams (ATMEGA238 max. limit).

The motor speed can be controlled using a Potentiometer to adjust the PWM signal.

A Photoswitch detects the slot in the wheel  for revolutions counting.

Minimot_GIF

The yellow Led  toggles every 30 revolutions.

Removing the offset weight, a no easy task.

Minimot_mass

Some Laser Cutting was done before put together all parts.

Disc_1_slotSoportes

How was connected to the Arduino pins:

Minimot_sch_

The final Assembly:

Final_Ass

The sketch used in the YouTube demostration:

/*------------------------------------------------------------------------------
  MiniMot_10
  Arduining.com  05 APRIL 2013
  
      The excentric mass is replaced by a disk in a Mini Vibrating Motor.
      A Motor Revolutions Counter is implemented using a photoswitch.   
      The Motor speed is controlled with a potentiometer.
      A led is toggled every 30 revolutions to show the motor speed.
      The PWM value is transmited to the Serial monitor.
  
      Arduino (ATMEGA328)drives directly the Motor, a series resistor
      of 75 ohms limits the current to 40 milliamps.
     
 -----------------------------------------------------------------------------*/
#define  MOT1    9        //Pin directly connected to the Motor.
#define  MOT2    10       //Pin connected to the Motor trhought a 75 Ohms resistor.
#define  LED     7        //Pin connected to the LED.
#define  POT     0        //Analog input for the potentiometer.
#define  PhotoSwitch  8   //Pin connected to the photoswitch.

#define  TURNS   30       //Number of turns to toggle the LED.

int Counter;              //Revolutions counter.
int PWMval;               //PWM Value to control the motor speed.
boolean WaitSlot= true;   //Flag used for slot detection.
boolean LedState= 0;      //1= on , 0= off

void setup() {                 
  pinMode(LED, OUTPUT);
  pinMode (PhotoSwitch, INPUT);
  Serial.begin(9600);
  analogWrite(MOT2, 0);    //pin 2 of the motor grounded.
}

void loop()
{
  PWMval=analogRead(POT)/4;  //read potentiometer.
  analogWrite(MOT1,PWMval);  //set the motor speed.

  if (!digitalRead(PhotoSwitch) && WaitSlot){  //slot detection!
    Counter++;
    WaitSlot=false;
    if (Counter == TURNS){
      LedState = !LedState;        // toggle the Led state.
      digitalWrite(LED,LedState);
      Serial.println(PWMval);
      Counter=0;                  //Reset the revolutions counter.
      }
    }

  else if (digitalRead(PhotoSwitch)) WaitSlot= true;  //No slot.

 }
Categories: Uncategorized

Optical Flow Sensor with Arduino Nano

January 26, 2013 Leave a comment

The Arduino Nano and Ten CdS Photoresistors are combined to realize an Optical Flow Sensor.

Pa05

Nine diferential measurements are obtained from every consecutive pair of photoresistors (edge detectors).

Digital pins are used as outputs  to produce +5Volts and Ground, and as inputs to produce High impedance).

Pa04

All the signals are captured in the analog input A0.

Pa29Pa35

Based in the work of Geoffrey L. Barrows, Centeye, Inc. Simple optical flow sensor using 18 CdS cells.

http://embeddedeye.com/profiles/blogs/make-an-optical-flow-sensor-using-an-arduino-cds-cells-and-a-shoe

Only the getImage() function was modified to  capture data.

The assembly procedure and test results can be seen in Youtube:

Aditional Tests made with the “Optic Flow Sensor”:

Categories: Uncategorized

New Arduino WiFi Shield (Testing)

November 10, 2012 Leave a comment

The WiFi Shield was delivered by Amazon.

The Arduino UNO Rev 3 was found at RadioShack…

First you need to load the last Arduino IDE (Ver 1.0.2) it has the necessary library to use the WiFi shield.

Tried the examples “Scan for available networks”  and  “WPA network example”

from:

http://arduino.cc/en/Guide/ArduinoWiFiShield

It works like a charm!

thanks Arduino Team…

Now some work is comming…

Thinking in some applications…

Categories: Uncategorized

Arduino Parking Lot ( Filled )

October 13, 2012 16 comments

Wiring diagram:

Here is the code:

/*ParkingL02.pde
Arduining.com 08 JUL 2012
Code used in the production of the Youtube material.
*/

#include <Servo.h>
Servo myservo;  // create servo object to control a servo

#define ServoM    12        //Connected to the servo motor.
#define Bright    11        //servo library disable PWM on pins 9 and 10.
#define Exit      9         //Pin connected to the EXIT button.
#define In        8         //Pin connected to the IN button.

#define BarLow    177       //Low position of the barrier.
#define BarUp     95        //Up position of the barrier.
#define CAPACITY  8         //Capacity of the parking lot.
#define INTEN     80        //Display intensity %

//Pins conections to segments (cathodes).
#define  segA  0
#define  segB  1
#define  segC  2
#define  segD  3
#define  segE  4
#define  segF  5
#define  segG  6

//Array with the segments to represent the decimal numbers (0-9).
byte segments[10] = {
// pgfedcba  <--- segments
  B00111111, // number 0
  B00000110, // number 1
  B01011011, // number 2
  B01001111, // number 3
  B01100110, // number 4
  B01101101, // number 5
  B01111101, // number 6
  B00000111, // number 7
  B01111111, // number 8
  B01101111  // number 9
};

void setup(){
  myservo.attach(ServoM);          // attaches the servo.

  pinMode(Exit, INPUT);           // set "EXIT" button pin to input
  pinMode(In, INPUT);             // set "IN" button pin to input
  digitalWrite(Exit, HIGH);       // Connect Pull-Up resistor.
  digitalWrite(In, HIGH);         // Connect Pull-Up resistor.
  pinMode(segA,OUTPUT);
  pinMode(segB,OUTPUT);
  pinMode(segC,OUTPUT);
  pinMode(segD,OUTPUT);
  pinMode(segE,OUTPUT);
  pinMode(segF,OUTPUT);
  pinMode(segG,OUTPUT);
  pinMode(Bright,OUTPUT);
  analogWrite(Bright,255*INTEN/100);
  myservo.write(BarLow);          //Barrier in the low position
//  delay(1000);
}

int  Available= 9;                    // Number of places available.

//================================================================
void loop(){
Display(Available);
if(digitalRead(In)==0)
{
  if(Available != 0){
    Available--;
    myservo.write(BarUp);
    delay(3000);
    myservo.write(BarLow);
    }
  }
if(digitalRead(Exit)==0)
{
  if(Available != CAPACITY){
    Available++;
    myservo.write(BarUp);
    delay(3000);
    myservo.write(BarLow);
    }
  }
}

/*-------------------------------------------------------------------
Put the segments according to the number.
--------------------------------------------------------------------*/
void Display(int number){
byte segs =  ~segments[number];        //"~" is used for commom anode.

digitalWrite(segA, bitRead(segs, 0) );
digitalWrite(segB, bitRead(segs, 1) );
digitalWrite(segC, bitRead(segs, 2) );
digitalWrite(segD, bitRead(segs, 3) );
digitalWrite(segE, bitRead(segs, 4) );
digitalWrite(segF, bitRead(segs, 5) );
digitalWrite(segG, bitRead(segs, 6) );
}

See it in Youtube:

and how was done:

Categories: Uncategorized

LaunchPad and Energia ( StopWatch )

September 12, 2012 Leave a comment

This is a simple project using the LaunchPad from Texas Instruments and Energia (Arduino-like IDE).

The Launchpad version 1.5 comes with the MSP430G2553 microcontroller, it has a hardware UART (use the  jumpers as shown in the image).

This is a funny and very low cost project.
The LaunchPad measures time (in microseconds) .The car travels a fixed distance between contacts (10 Cms).

Time is measured using  START and STOP contact switches.
Contact switches are implemented using neodymium magnets.

You’ll need small nails, miniature neodymium magnets and colors headed pins to  assemble the switches.

Here is the code used:

/* Cronometer01.ino
  Arduining.com 25/AUG/12
  Used in the LaunchPad V-1.5 with the MSP430G2553
  Measuring time between the signals of START and STOP  in microseconds.
  The result is sent serial at 9600 bauds.
  
  GREEN LED on indicate READY TO START.
  RED LED on indicate MEASURING TIME.
  RED LED blinking indicate MEASURE DONE.
  
  Push RESET in the LaunchPad to repeat the measurement. 
 */
#define START  11     //Pin P2.3
#define STOP   12     //Pin P2.4

unsigned long time;

void setup() {
  pinMode(START,INPUT_PULLUP);  //internal pull-up
  pinMode(STOP,INPUT_PULLUP);   //internal pull-up
  pinMode(GREEN_LED, OUTPUT);     
  pinMode(RED_LED, OUTPUT);
  Serial.begin(9600);  
}

void loop() {
  Serial.println("READY");
  digitalWrite(GREEN_LED, HIGH);   // set the GREEN LED on
  digitalWrite(RED_LED, LOW);      // set the RED LED off

  while(!digitalRead(START)){}
  time = micros();
  digitalWrite(GREEN_LED, LOW);    // set the GREEN LED off
  digitalWrite(RED_LED, HIGH);     // set the RED LED on

  while(!digitalRead(STOP)){}  
  time = micros()-time;
  digitalWrite(RED_LED, LOW);      // set the RED LED off
  Serial.print(time);
  Serial.println(" Microseconds");

  while(1){                        // Blink to indicate END.
    delay(900);                    // wait 0.9 second
    digitalWrite(RED_LED, HIGH);   // set the RED LED on
    delay(100);                    // wait 0.1 second
    digitalWrite(RED_LED, LOW);    // set the RED LED off
  }

}

See it in YouTube:

Categories: Uncategorized
Follow

Get every new post delivered to your Inbox.