Posts with «arduino uno r3» label

Build an 8-Key Piano on a Breadboard with Arduino

An 8-key piano on a breadboard with an Arduino Uno R3, eight 6×6 mm tactile buttons and a passive piezo buzzer. Each key you press plays a note of the C major scale, from C4 at 262 Hz up to C5 at 523 Hz. That is enough to play tunes like Twinkle Twinkle Little Star. No shield, no external library and no soldering are needed: just a breadboard, jumpers and a USB cable.

Assembly is the quickest part. The tactile buttons go into the breadboard straddling the centre channel, one next to the other. Each button has one side connected to an Arduino digital pin and the other side to GND. The passive buzzer has its positive leg on pin D10 and its negative leg on GND. A jumper connects the breadboard’s GND rail to the board’s ground.

The keys occupy pins D2 to D9, eight consecutive digital pins. The Arduino Uno has 14 digital pins (D0-D13) and 6 analog pins usable as digital inputs, so there is plenty of room to add keys in a later version. For the keys, the catalogue has a 6×6 mm PCB mini pushbutton, the same format used in the project.

INPUT_PULLUP and the tone() function in the firmware

The code uses no library: it relies on the tone() function built into the Arduino IDE. Each button is connected between a pin and GND, so the firmware enables the internal pull-up resistor with INPUT_PULLUP. As a result the pin reads HIGH when the key is at rest and LOW when it is pressed. The code scans the eight pins, stores the first key pressed and calls tone() with the associated frequency.

The comparison if (pressedKey != lastKey) makes tone() fire only once per press, instead of repeating the call on every pass of the loop. When no key is pressed, the code calls noTone() and the sound stops. The serial monitor opens at 9600 baud and is used to check which keys are being read during testing.

  • Key 1: C4 at 262 Hz
  • Key 2: D4 at 294 Hz
  • Key 3: E4 at 330 Hz
  • Key 4: F4 at 349 Hz
  • Key 5: G4 at 392 Hz
  • Key 6: A4 at 440 Hz
  • Key 7: B4 at 494 Hz
  • Key 8: C5 at 523 Hz

The piano is monophonic, and that is a limitation of the tone() function: it generates only one frequency at a time. So if you press two keys together, the one with the lower number wins, that is, the first one the loop encounters. Anyone who wants real chords has to change approach, for example generating the waveforms by hand with a timer.

Passive buzzer, current draw and an alternative speaker

The passive piezo buzzer works from 3.3V to 5V and draws less than 30 mA, so you can drive it straight from an Arduino pin without a transistor. Its best output is around 2-4 kHz, while the notes of this piano run from 262 Hz to 523 Hz. The sound comes out, but don’t expect concert volume: to raise the sound pressure, a speaker is a better bet.

Instead of the buzzer you can use an 8 ohm speaker with a 100 ohm resistor in series. The resistor limits the current and protects the pin. On top of that, the sound is fuller on the low notes of the scale. The rest of the circuit does not change: positive on D10, negative on GND.

Rebuilding the project takes only a few parts: an Arduino Uno R3, eight 6×6 mm tactile buttons, a passive piezo buzzer, a breadboard, jumpers and a USB cable. The cost is low and so is the difficulty. In fact it is an ideal first project for learning about digital inputs, INPUT_PULLUP and the tone() function, and you can finish it in an evening.

If you want to see the build in action, on the maker’s site you will find the video with the piano played key by key. There you can see how the buzzer behaves on the different notes before soldering or buying anything.

Source: https://www.circuitschools.com/arduino-piano-project-with-8-keys-build-a-simple-piano/

Related products

The post Build an 8-Key Piano on a Breadboard with Arduino appeared first on Open Electronics.

First Robot - Arduino + Processing

Primary image

What does it do?

Remote Controlled Robot, Navigate around via ultrasound

After some weeks of browsing this website, I felt inspired to built something, so, here is the first robot that I'm currently working on.

The idea of this project is to have a platform that can be controlled remotely or work autonomously. For the initial fase, I'm working on some basic remote programmed on Processing, which send commands to the robot via bluetooth (using controlP5 for the UI, and bluetoothDesktop to handle bt communication).

Cost to build

$100,00

Embedded video

Finished project

Number

Time to build

10 hours

Type

wheels

URL to more information

Weight

read more

Atom 1.2 Upgraded with Bluetooth

Primary image

What does it do?

users controlled through Tera Term - Using Bluetooth

Atom 1.0: http://letsmakerobots.com/node/31322

My previous Arduino project had a controller that was connected to Atom and powered by my laptop. 

Parts: 

Cost to build

$80,00

Embedded video

Finished project

Number

Time to build

15 hours

Type

tracks

URL to more information

Weight

250 grams

read more

BioBot v1

Primary image

What does it do?

Exhibits all 7 characteristics of life, therefore technically it is an organism.

Wonders around autonomously. Exhibits all 7 characteristics of life, therefore technically it is an organism.

Cost to build

$50,00

Embedded video

Finished project

Number

Time to build

6 hours

Type

URL to more information

Weight

Bøsewicht

Primary image

What does it do?

Scares People

This is the Bøsewicht. A ghost robot custom made together with my elder son.

This little monster ghost is what you find under your bed when you sleep. The only one that can handle this monster is the Monster Catcher*.

 

Ingredients

2 x 9g Micro Servo
1 x Arduino Uno R3
3 x LED warm white 
1 x LED red  
1 x Speaker
1 x Ultrasonic Sensor
1 x IR Compound Eye 

 

The Making-Of

Cost to build

$30,00

Embedded video

Finished project

Number

Time to build

8 hours

Type

URL to more information

Weight

300 grams

read more

Monster Catcher

Primary image

What does it do?

Catches Monsters Under the Bed

This is the LMR robot for the today's Campus-Party Berlin. Its purpose in life is to help children if they are afraid of monsters in the night. The Monster Catcher stays under the bed and makes noises to catch the monsters...

The Monster Catcher is a collective work of Drakuni, Antonio, Isotope, TinHead, Frits, RobotFreak, Lumi and Francisco.

The Making

Here some impressions from the making.

Frits, Nils and Antonio elaborate on the ideas. It is important that it is a very easy-to-make robot that does not need rocket science software and hardware.

Cost to build

$20,00

Embedded video

Finished project

Number

Time to build

10 hours

Type

URL to more information

Weight

300 grams

read more

Sunny the RFID lion

Primary image

What does it do?

Reads RFID tags then plays .wav files, also uses a mic to hear loud nosies.

     This is a copy of the RFID bear on Make. I have however added a few new features in the code like a ram check, a random file player and a sound response. The random file player I adds another dimension to the character. If you would like to make you own it is very easy.

Cost to build

$130,00

Embedded video

Finished project

Complete

Number

Time to build

5 hours

Type

URL to more information

Weight

1200 grams

read more

n/a

n/a