Showing posts with label buy an arduino board. Show all posts
Showing posts with label buy an arduino board. Show all posts

Saturday, November 28, 2015

How to make Arduino Trumpet-Robomart

This is simple project using the three buttons, emulates a trumpet by playing notes. This is so easy to make and fun to play with, though it can only play one octave and no flats.
Step 1: Code

Load this code into your Arduino:
int speaker = 9; // Hook up speaker to digital pin 9
int sw1 = 15; // Switch hooked to analog pin 1
int sw2 = 16; // Switch hooked to analog pin 2
int sw3 = 17; // Switch hooked to analog pin 3
int valve1; 
int valve2; 
int valve3; 

void c () { // Presets the note "c" to be used later
digitalWrite(speaker, HIGH);
delayMicroseconds(1915);
digitalWrite(speaker, LOW);
delayMicroseconds(1905);
}
void d () {
digitalWrite(speaker, HIGH);
delayMicroseconds(1700);
digitalWrite(speaker, LOW);
delayMicroseconds(1690);
}
void e () {
digitalWrite(speaker, HIGH);
delayMicroseconds(1519);
digitalWrite(speaker, LOW);
delayMicroseconds(1509);
}
void f () {
digitalWrite(speaker, HIGH);
delayMicroseconds(1432);
digitalWrite(speaker, LOW);
delayMicroseconds(1422);
}
void g () {
digitalWrite(speaker, HIGH);
delayMicroseconds(1275);
digitalWrite(speaker, LOW);
delayMicroseconds(1265);
}
void a () {
digitalWrite(speaker, HIGH);
delayMicroseconds(1136);
digitalWrite(speaker, LOW);
delayMicroseconds(1126);
}
void b () {
digitalWrite(speaker, HIGH);
delayMicroseconds(1014);
digitalWrite(speaker, LOW);
delayMicroseconds(1004);
}
void C () {
digitalWrite(speaker, HIGH);
delayMicroseconds(956);
digitalWrite(speaker, LOW);
delayMicroseconds(946);
}

void setup() {
pinMode(speaker, OUTPUT);
pinMode(sw1, INPUT);
digitalWrite(sw1, HIGH);
pinMode(sw2, INPUT);
digitalWrite(sw2, HIGH);
pinMode(sw3, INPUT);
digitalWrite(sw3, HIGH);
// Serial.begin(9600);
}

void loop() {
valve1 = digitalRead(sw1); // Reads switch 1
valve2 = digitalRead(sw2); // Reads switch 2
valve3 = digitalRead(sw3); // Reads switch 3

if ((valve1 == LOW) && (valve2 == LOW) && (valve3 == LOW)) { // If all valves are pressed, then
c(); // It plays a "c"
}
else if ((valve1 == LOW) && (valve2 == HIGH) && (valve3 == LOW)) { // If the first and third valves are pressed, then
d(); // It plays a "d"
}
else if ((valve1 == LOW) && (valve2 == LOW) && (valve3 == HIGH)) { // If the first and second valves are pressed, then
e(); // It plays a "e"
}
else if ((valve1 == LOW) && (valve2 == HIGH) && (valve3 == HIGH)) { // If the first valve is pressed, then
f(); // It plays a "f"
}
else if ((valve1 == HIGH) && (valve2 == HIGH) && (valve3 == HIGH)) { // If no valves are pressed, then
g(); // It plays a "g"
}
else if ((valve1 == HIGH) && (valve2 == HIGH) && (valve3 == LOW)) { // If the third valve is pressed, then
a(); // It plays a "a"
}
else if ((valve1 == HIGH) && (valve2 == LOW) && (valve3 == HIGH)) { // If the second valve is pressed, then
b(); // It plays a "b"
}
else if ((valve1 == HIGH) && (valve2 == LOW) && (valve3 == LOW)) { // If the second and third valves are pressed, then
C(); // It plays a "C"
}
else{
delay(1);
}
}
Step 2: How can hook it up
Each of the three switches go to analog from ground in 1, 2, and 3. The Piezo goes from digital pin 9 to ground. Make sure to have the switches in the right order in order to have the correct fingerings. Afterwords, download the file and upload it to your Arduino.
Step 3: Resources

For this project you will need: 
Project box (4x2x1) 
Drill and 1/4 in bit along with 1/16 in
•3 momentary switches (NO) 
Step 4: Put it Together!!
First of all, open the box and on the outside of the box, mark the center and an inch out from the center. Where you will need to make a 1/4 in hole Now, dremel out the scraps of plastic and used the holders to hold a PC inside.
Step 5: How can I Fit it!



Insert switches and make sure that they fit and screw them . They are situated in the right place and enter the PIN and drill bit to drill holes with a 1/16 mark .
Step 6: Wireing

Now, wire and solder each of the analog input posts and attach the other side to the corresponding switch. Make sure to not get mixed up and solder the wrong switch to the wrong pin. Like before, solder the piezo to pin 9 and ground and the battery clasp to ground and voltage in. 
Step 7: Playing
Fingerings on the trumpet to trumpet a general ' as are' . ' Identical ' I mean , I had to make some changes .


on a normal trumpet its like this:
c..........0pen
d..........1-3
e..........1-2
f ..........1
g..........0pen / 1-3
a..........1-2 / 3
b..........2
C..........0pen / 2-3
________________________________________
On the Arduino Trumpet:
c..........1-2-3
d..........1-3
e..........1-2
f ..........1
g..........0pen
a..........3
b..........2
C..........2-3

I used half-step complicated and changing things and switches can put a octive . It would be awsome , however , it may be more complex and will require a large box .
HAVE FUN!!!!

Thursday, November 26, 2015

Controlling of 8 LEDs by using Arduino UNO-Robomart

The step wise processor to control 8 LEDs using Arduino. This is a simple tutorial to control 8 LEDs using Arduino. This tutorial is very simple but more interesting. In this tutorial you set up LEDs to your breadboard.
 Step 1: What you will need


The parts are very simple for this easy project.
LEDs (3 red, 3 green and 2 blue)
Step 2: Put the LEDs and wires
In this step first of all you will need some parts which is mentioned in 2nd step after take the parts and LEDs you have to place the LEDs on the breadboard and you have reserved the positive  wire on the right side . After the wiring you will need to upload the code. The code is given below in 3rd step please upload this code and complete your project.
Step 3: Upload the code
//LED Pin Variables
int ledPins[] = {2,3,4,5,6,7,8,9}; //An array to hold the pin each LED is connected to
                                   //i.e. LED #0 is connected to pin 2, LED #1, 3 and so on
                                   //to address an array use ledPins[0] this would equal 2
                                   //and ledPins[7] would equal 9

/*
* setup() - this function runs once when you turn your Arduino on
* We the three control pins to outputs
*/
void setup()
{

  //Set each pin connected to an LED to output mode (pulling high (on) or low (off)
  for(int i = 0; i < 8; i++){         //this is a loop and will repeat eight times
      pinMode(ledPins[i],OUTPUT); //we use this to set each LED pin to output
  }                                   //the code this replaces is below




/*
* loop() - this function will start after setup finishes and then repeat
* we call a function called oneAfterAnother(). if you would like a different behaviour
* uncomment (delete the two slashes) one of the other lines
*/
void loop()                     // run over and over again
{
  oneAfterAnotherNoLoop();   //this will turn on each LED one by one then turn each off

}


void oneAfterAnotherNoLoop(){
  int delayTime = 100; //the time (in milliseconds) to pause between LEDs
                       //make smaller for quicker switching and larger for slower
  digitalWrite(ledPins[0], HIGH);  //Turns on LED #0 (connected to pin 2 )
  delay(delayTime);                //waits delayTime milliseconds
  digitalWrite(ledPins[1], HIGH);  //Turns on LED #1 (connected to pin 3 )
  delay(delayTime);                //waits delayTime milliseconds
  digitalWrite(ledPins[2], HIGH);  //Turns on LED #2 (connected to pin 4 )
  delay(delayTime);                //waits delayTime milliseconds
  digitalWrite(ledPins[3], HIGH);  //Turns on LED #3 (connected to pin 5 )
  delay(delayTime);                //waits delayTime milliseconds
  digitalWrite(ledPins[4], HIGH);  //Turns on LED #4 (connected to pin 6 )
  delay(delayTime);                //waits delayTime milliseconds
  digitalWrite(ledPins[5], HIGH);  //Turns on LED #5 (connected to pin 7 )
  delay(delayTime);                //waits delayTime milliseconds
  digitalWrite(ledPins[6], HIGH);  //Turns on LED #6 (connected to pin 8 )
  delay(delayTime);                //waits delayTime milliseconds
  digitalWrite(ledPins[7], HIGH);  //Turns on LED #7 (connected to pin 9 )
  delay(delayTime);                //waits delayTime milliseconds 

//Turns Each LED Off
  digitalWrite(ledPins[7], LOW);  //Turns on LED #0 (connected to pin 2 )
  delay(delayTime);                //waits delayTime milliseconds
  digitalWrite(ledPins[6], LOW);  //Turns on LED #1 (connected to pin 3 )
  delay(delayTime);                //waits delayTime milliseconds
  digitalWrite(ledPins[5], LOW);  //Turns on LED #2 (connected to pin 4 )
  delay(delayTime);                //waits delayTime milliseconds
  digitalWrite(ledPins[4], LOW);  //Turns on LED #3 (connected to pin 5 )
  delay(delayTime);                //waits delayTime milliseconds
  digitalWrite(ledPins[3], LOW);  //Turns on LED #4 (connected to pin 6 )
  delay(delayTime);                //waits delayTime milliseconds
  digitalWrite(ledPins[2], LOW);  //Turns on LED #5 (connected to pin 7 )
  delay(delayTime);                //waits delayTime milliseconds
  digitalWrite(ledPins[1], LOW);  //Turns on LED #6 (connected to pin 8 )
  delay(delayTime);                //waits delayTime milliseconds
  digitalWrite(ledPins[0], LOW);  //Turns on LED #7 (connected to pin 9 )
  delay(delayTime);                //waits delayTime milliseconds 
}


void oneAfterAnotherLoop(){
  int delayTime = 100; //the time (in milliseconds) to pause between LEDs
                       //make smaller for quicker switching and larger for slower

//Turn Each LED on one after another
  for(int i = 0; i <= 7; i++){
    digitalWrite(ledPins[i], HIGH);  //Turns on LED #i each time this runs i
    delay(delayTime);                //gets one added to it so this will repeat
  }                                  //8 times the first time i will = 0 the final
                                     //time i will equal 7;

//Turn Each LED off one after another
  for(int i = 7; i >= 0; i--){  //same as above but rather than starting at 0 and counting up
                                //we start at seven and count down
    digitalWrite(ledPins[i], LOW);  //Turns off LED #i each time this runs i
    delay(delayTime);                //gets one subtracted from it so this will repeat
  }                                  //8 times the first time i will = 7 the final
                                     //time it will equal 0
                                    
                                    
}

/*
* oneOnAtATime() - Will light one LED then the next turning off all the others
*/
void oneOnAtATime(){
  int delayTime = 100; //the time (in milliseconds) to pause between LEDs
                       //make smaller for quicker switching and larger for slower

  for(int i = 0; i <= 7; i++){
    int offLED = i - 1;  //Calculate which LED was turned on last time through
    if(i == 0) {         //for i = 1 to 7 this is i minus 1 (i.e. if i = 2 we will
      offLED = 7;        //turn on LED 2 and off LED 1)
    }                    //however if i = 0 we don't want to turn of led -1 (doesn't exist)
                         //instead we turn off LED 7, (looping around)
    digitalWrite(ledPins[i], HIGH);     //turn on LED #i
    digitalWrite(ledPins[offLED], LOW); //turn off the LED we turned on last time
    delay(delayTime);
  }
}

/*
* inAndOut() - This will turn on the two middle LEDs then the next two out
* making an in and out look
*/
void inAndOut(){
  int delayTime = 100; //the time (in milliseconds) to pause between LEDs
                       //make smaller for quicker switching and larger for slower

  //runs the LEDs out from the middle
  for(int i = 0; i <= 3; i++){
    int offLED = i - 1;  //Calculate which LED was turned on last time through
    if(i == 0) {         //for i = 1 to 7 this is i minus 1 (i.e. if i = 2 we will
      offLED = 3;        //turn on LED 2 and off LED 1)
    }                    //however if i = 0 we don't want to turn of led -1 (doesn't exist)
                         //instead we turn off LED 7, (looping around)
    int onLED1 = 3 - i;       //this is the first LED to go on ie. LED #3 when i = 0 and LED
                             //#0 when i = 3
    int onLED2 = 4 + i;       //this is the first LED to go on ie. LED #4 when i = 0 and LED
                             //#7 when i = 3
    int offLED1 = 3 - offLED; //turns off the LED we turned on last time
    int offLED2 = 4 + offLED; //turns off the LED we turned on last time
   
    digitalWrite(ledPins[onLED1], HIGH);
    digitalWrite(ledPins[onLED2], HIGH);   
    digitalWrite(ledPins[offLED1], LOW);   
    digitalWrite(ledPins[offLED2], LOW);       
    delay(delayTime);
  }

  //runs the LEDs into the middle
  for(int i = 3; i >= 0; i--){
    int offLED = i + 1;  //Calculate which LED was turned on last time through
    if(i == 3) {         //for i = 1 to 7 this is i minus 1 (i.e. if i = 2 we will
      offLED = 0;        //turn on LED 2 and off LED 1)
    }                    //however if i = 0 we don't want to turn of led -1 (doesn't exist)
                         //instead we turn off LED 7, (looping around)
    int onLED1 = 3 - i;       //this is the first LED to go on ie. LED #3 when i = 0 and LED
                             //#0 when i = 3
    int onLED2 = 4 + i;       //this is the first LED to go on ie. LED #4 when i = 0 and LED
                             //#7 when i = 3
    int offLED1 = 3 - offLED; //turns off the LED we turned on last time
    int offLED2 = 4 + offLED; //turns off the LED we turned on last time
   
    digitalWrite(ledPins[onLED1], HIGH);
    digitalWrite(ledPins[onLED2], HIGH);   
    digitalWrite(ledPins[offLED1], LOW);   
    digitalWrite(ledPins[offLED2], LOW);       
    delay(delayTime);
  }
}
After the wiring and uploading code you have successfully completed this project easily . If you find it attractive sufficient, you are free to edit it and use in your work. Feel free to comment and give suggestions in the comments section below.

Monday, November 23, 2015

Arduino - Bluetooth communication by Robomart

We have a tutorial session via Bluetooth communication between Arduino and computing are going to see In order for us to do that , a reasonable price we are going to use the court 06bluetooth board. We had some data to the stream , so that you need to build a simple Arduino sensor circuit are going to . Why not try to project our light sensor.
 Step 1: How to Wire up your Arduino 



Once we have some data to send , we need to connect the Bluetooth board 
Arduino side , the connecting wires
•A black wire to one of the GND pins
•A blue wire to digital pin 1 (usually marked TX for "transmit")
•A red wire from the 5v pin on the Arduino
•An orange wire to digital pin 0 (usually marked RX for "receive")
•A black wire to one of the GND pins
The red and black wires , Bluetooth Arduino board will provide power to the blue wire outgoing data and incoming data will bring the orange wire .
Step 2: Voltage divider

There's a problem.(Arduinos out there are many ) that we are using a 5V Arduino board , but the Bluetooth board input and output pins are only 3.3 volts . We send 5 volts to the Bluetooth board , then it would probably burn out .
For this reason , we have a " voltage divider " the need to build something - it's basically the Bluetooth board and (GND pin ) through the back rest to the Arduino to send something , two voltage divider that is a simple circuit .
Voltage divider resistors to build two are going to need . That one needs to be twice that of the other - except in the value of the resistors does not matter . We use a 200k resistor and a 100k resistor are . As shown in the picture with wire resistors :
•A black wire connected to the larger resistor (200k) - this black wire should lead back to any of the GND pins on the Arduino.
•A white wire connected to both resistors.The blue wire from the Arduino connected to the smaller resistor (100k).
WARNING: As shown in the picture , or you risk damaging your Bluetooth board just as sure to wire their circuits !
Step 3: How can wired up your Bluetooth board

As shown in the picture for us to provide a safe input signal is a voltage divider that , we can wire the Court 06 Bluetooth board :
•Connect the white wire from the voltage divider to the RX pin on the bluetooth board
•Connect the black GND wire from the Arduino to the GND pin on the bluetooth board
•Connect the orange wire from the Arduino to the TX pin on the bluetooth board
•Connect the red (5v) wire from the Arduino to the VCC pin on the bluetooth board
Step 4: Pair your computer with the Bluetooth board
We Arduino and the computer before starting the dialogue between the two needs to be added .
This process will depend on the operating system you are using - check their documentation for information
Bluetooth board is powered up and is looking for , so that should be on your Arduino 
Step 5: Select the Bluetooth serial connection

If your computer is paired with your Bluetooth board once , a new Bluetooth serial port Arduino IDE " port " will appear in the menu . This name is usually the name of the Bluetooth device will include ( in the photo above gives you we 've got boards that can see several HC- 06 ) .
Select the Bluetooth serial port from your ports list.
This time has been , (Serial. println use functions ) Arduino sent any data to be received by your computer via Bluetooth .
Step 6: Connect via Serial Monitor

Open Arduino by clicking on the magnifying glass icon on the top right of the window " Serial Monitor " above . Serial monitoring should look like over - " 9600 baud " window that has been selected in the dropdown menu below to make sure . Now any data appearing in the window that is being sent from your Arduino to be able to see it.
Step 7: Enjoy
Everything worked, so you should be able to receive data wirelessly from the Arduino. Equally, you also can send data wirelessly to your Arduino computing. It normally Serial Monitor can be used. Alternatively, you with your Arduino via serial communication that can write desktop applications.

Friday, November 20, 2015

How to make Arduino remotely controlled by Bluetooth or Bluetooth LE using phone - Robomart

Ever wanted to remotely control your Arduino ? Or read sensor values​​, or to make it something ? Maybe even create a remotely controlled robot ? Well now you can. The most basic example will cover; Switch off the LED on  and off .





Step -1: what you will need

  • 1 x 220 ohm (or similar) resistor
  • Assorted wire
  • 1 x smart phone (currently the app we will use only support
  • Android, but we are working on getting it accepted for iOS AppStore).
  • To use with a Bluetooth LE unit, the phone must support Bluetooth LE.
  • 1 x LED
  • 1 x Bluetooth or Bluetooth LE unit. The ones we have tested and works:
  • Bluetooth: HC-05 and HC-06 (will not be supported for iOS)
  • Bluetooth LE: HM-10

Step -2 : Hooking Everything Up 

Only now called BT ) Bluetooth or Bluetooth to connect the unit to :

Step-3: Code to the Arduino

5  ArduinoMobileIntegrationExamples/README.md
@@ -67,6 +67,11 @@ To run in app, copy the following files to the Internet:
An example that shows how a push button may be implemented in the app, and
state reported to an Arduino through a Bluetooth device.

+Two versions of Arduino code:
+* One using `PLabBTSerial.h` located in our `PLabBT` library.
+* One using only `SoftwareSerial.h` and a simple state machine to parse
+incomming text
+
To run in app, copy the following files to the Internet:
* `SimpleButtonExample.pde`


View
114  ...onExample/Arduino/SimpleButtonExampleSoftwareSerial/SimpleButtonExampleSoftwareSerial.ino
@@ -0,0 1,114 @@
/*
 * SimpleButtonExample SoftwareSerial
 *
 * Fjernstyr en LED på Arduine ved hjelp av SoftwareSerial og en tilstandsmaskin.
 *
 * Remotely controlled LED on Arduino using SoftwareSerial and a simple state machine.
 */
#include <SoftwareSerial.h>

// Enum definisjon. Brukt for å parse innkommende tekst
// Enum definition. Used to parse incomming text.
enum ReadState { INIT, O_ACCEPTED, F_ACCEPTED, END };

// State of parser
ReadState myState = INIT;

// Definer inn/utgangspinnene som brukes for send (TX) og motta (RX) for bluetooth
// Define I/O ports used for transmit (TX) and receive (RX)
const int BT_RX = 10;
const int BT_TX = 11;


// Hvilken utgang vi har lysene paa
// Which output we have the lights connected to
const int LIGHT_OUT = 4;


// Definer serieporten for kommunikasjon med bluetooth
// Define the serial port for communication with bluetooth
SoftwareSerial btSerial (BT_RX, BT_TX);

void setup() {
  // Start kommunikasjon med konsoll
  // Start communication throuhg console
  Serial.begin (9600);
  // Linja under trengs kun for Leonardo (kan slettes om du bruker Arduino UNO)
  // The following line is only needed for Leonardo (can be deleted if you are using Arduino UNO)
  while (!Serial);
  Serial.println ("Enkel knapp demonstrasjon med BLUETOOTH");
 
  // Setter utgangen for lyset
  // Set the output for our light
  pinMode (LIGHT_OUT, OUTPUT);
  digitalWrite (LIGHT_OUT, LOW);
 
  // Start kommunikasjonen med bluetooth enhet
  // Start communication with bluetooth unit
  btSerial.begin (9600);
}

void loop() {
  // Sjekker om vi har mottatt noe fra bluetooth enhet
  // See if anything has been received by Bluetooth unit
  if (btSerial.available()) {
    // Les mottatt bokstav
    // Read received character
    char recv = btSerial.read();

    // Gjør valg avhengig av tilstand
    // Do choises dependent on state
    switch (myState)
    {
      // INIT og END tilstand er egentlig like
      // INIT and END state are actually the same
      case INIT:  // Fallthrough
      case END:
        // Første bokstav vi aksepterer er kun en 'O'
        // First accepted is only an 'O'
        if (recv == 'O')
          myState = O_ACCEPTED;
        else
          myState = END;
        break;
      case O_ACCEPTED:
        // Andre bokstav kan enten være en ny 'O', en 'N' eller 'F'
        // Second character can either be an 'O', 'N' or 'F'
        switch(recv) {
          case 'O':
            myState = O_ACCEPTED;
            break;
          case 'N':
            myState = END;
            digitalWrite(LIGHT_OUT, HIGH);
            break;
          case 'F':
            myState = F_ACCEPTED;
            break;
          default:
            myState = END;
        }
        break;
      case F_ACCEPTED:
        // 'O' og 'F' er akseptable bokstaver
        // 'O' and 'F' are acceptable characters
        switch(recv) {
          case 'O':
            myState = O_ACCEPTED;
            break;
          case 'F':
            myState = END;
            digitalWrite(LIGHT_OUT, LOW);
            break;
          default:
            myState = END;
        }
        break;
    }
  }
  // Hvis vi har lyst til aa kunne skrive kommandoer i konsollvinduet, tar vi med dette
  // If we want to be able to write commands in the console window, we include this
  if (Serial.available () > 0) {
    btSerial.write (Serial.read ());
  }
}

When you have selected a version of the code.

  • Connect the Arduino to your computer.
  • Open the source file.
  • Press upload.

Step-4: Download the PLab app




Step-5: Running the sketch

First , sketch app can find it , a place where there should be . This means it must be uploaded to the Internet .
InterfacesInc.pde only need to upload the app so SimpleButtonExample.pde , internally covers
Sketch run , first connect the device to your Bluetooth or Bluetooth
  • Select the device from the list
  • Select wheter you want to connect to a Bluetooth or a Bluetooth LE device. To connect to a Bluetooth unit, this unit has to be paired with your phone. This is not neccessary when working with Bluetooth LE.
  • It is already uploaded here , it should be possible to directly use the upload . Be aware , and feeds into the app . This can be done by :
  • Leave settings andpainstakingly write the entire address into the "Sketch ID" field.
  • Go to settings and delete "URL address base" and "URL address end" 
If you have access to a web area , then use this to store your samples will be very easy to do .
After successfully loading the sketch , a white button should be visible on the brown background . Pressing the button to go dark a