Posts with «arduino uno» label

Simon Says, But With Servos

How much easier would life be if you could just grab hold of whatever mechanism you wanted to manipulate, move it like you want, and then have it imitate your movements exactly? What if you could give a servo MIDI-like commands that tell it to move to a certain location for a specific duration? Wonder no more, because [peterbiglab] has big-brained the idea into fruition.

With just one wire, an Arduino, and some really neat code, [peter] can get this servo to do whatever he wants. First he tells the Arduino the desired duration in frames per second. Then he grabs the horn and moves it around however he wants — it can even handle different speeds. The servo records and then mimics the movements just as they were made.

The whole operation is way simpler than you might think. As [peterbiglab] demonstrates in the video after the break, the servo knows its position thanks to an internal potentiometer on the motor’s rotor. If you locate the pot output pin on the control board and run a wire from there into an Arduino, you can use that information to calibrate and control the servo’s position pretty easily. There are a ton of possibilities for this kind of control. What would you do with it? Let us know in the comments.

If you want to try this with a bunch of servos at once, might as well build yourself a little testing console.

Via r/duino

Offline Dinosaur-Jumping Becomes a Real Workout

It’s great to see people are out there trying to find fun ways to exercise amid the current crisis. Although jumping up and down isn’t great for the knees, it does give decent cardio. But if you don’t have a rope or a puddle, we admit that jumping can lose its bounce pretty fast.

Quarantine has been a game-filled time for [fridaay]. Somewhere between a handful of FPS games, he decided to try to play Google’s offline dinosaur-based side scroller game by making the dinosaur spring over the saguaros whenever he physically jumps in the air. (Video, embedded below.)

Here’s how it works: [fridaay] holds a transmit circuit that consists of an Arduino UNO, an accelerometer module, and an nRF24L01 transceiver, all running on a 9 V battery. Whenever [fridaay] jumps, the accelerometer reads the change in Z and sends it to the receiving circuit, which is just another UNO and nRF. The receiving UNO is connected to a laptop and configured to press the space bar so the dinosaur canters over the cacti.

We’ve never been able to stay alive long enough in the game to see this happen, but apparently you need to crouch at some point in the game. [fridaay] has yet to implement a control for that, but we’re sure he’ll think of something. Jump past the break to see the video, and hit him up if you need the code.

If you have a lot of parts at your disposal, why not make a physical version?

Via r/duino

Self-Playing Whistle While You Work From Home

In ridiculous times, it can help to play ridiculous instruments such as the slide whistle to keep your bristles in check. But since spittle is more than a little bit dangerous these days, it pays to come up with alternative ways to play away the days during lockdown life.

Thanks to some clever Arduino-driven automation, [Gurpreet] can maintain a safe distance from his slide whistle while interacting with it. Slide whistles need two things — air coming in from the top, and actuation at the business end. The blowing force now comes from a focused fan like the ones that cool your printed plastic as soon as the hot end extrudes it. A stepper motor moves the slide up and down using a printed rack and pinion.

Here’s a smooth touch — [Gurpreet] added a micro servo to block and unblock the sound hole with a cardboard flap to make the notes more distinct. Check out the build video after the break, which includes a music video for “My Heart Will Go On”, aka the theme from Titanic. It’s almost like the ship herself is playing it on the steam whistles from the great beyond.

Speaking of, did you hear about the effort to raise and restore the remains of her radio room?

Slippy Slapper Uselessly Uses All the Arduinos

Want to take that annoyingly productive coworker down a notch? Yeah, us too. How dare they get so much done and be so happy about it? How is it possible that they can bang on that keyboard all day when you struggle to string together an email?

The Slippy Slapper is a useless machine that turns people into useless machines using tactics like endless distraction and mild physical violence. It presses your buttons by asking them to press buttons for no reason other than killing their productivity. When they try to walk away, guess what? That’s another slappin’. Slippy Slapper would enrage us by proxy if he weren’t so dang cute.

You’re right, you don’t need an Arduino for this. For peak inefficiency and power consumption, you actually need four of them. One acts as the master, and bases its commands to the other three on the feedback it gets from Slippy’s ultrasonic nostrils. The other three control the slappin’ servos, the speakers, and reading WAV files off of the SD card. Slap your way past the break to see Slippy Slapper’s slapstick demo.

Need to annoy a group of coworkers all at once? Slip a big bank of useless machines into the conference room while it’s being set up.

Vocal Effects On The Arduino Uno

When one thinks of audio processing, the mind doesn’t usually leap to an 8-bit micro. Despite this, if you’re looking for some glitchy fun, it’s more than possible, as [Amanda Ghassaei] demonstrates with the Arduino Uno in this 2012 throwback project.

The build is designed for vocal effects, based on the idea of granular synthesis. This is where audio samples are chopped up into small chunks, called “grains”, and manipulated in various ways to make fun sounds. Controls on the box allow the nature of the sound created to be modified by the user.

[Amanda]’s project serves as a great example of what it takes to run audio processing on the Arduino Uno. There’s a guide to using the on-board ADC as a microphone input, as well as the construction of a resistor ladder DAC for output. As a neccessity, this also requires discussion of how to write directly to the ATMEGA’s IO ports, rather than using the slower digitalWrite() function typically used in Arduino projects. There’s plenty of value here for anyone learning to do audio on a microcontroller platform.

Overall, it’s a fun project that serves as a good primer for those keen to dive into digital sound processing. Of course, those looking to kick things up a gear would do well to check out the Teensy Audio Library, too. Video after the break.

IoT Safe Keeps Latchkey Kids’ Phones on Lockdown

Phones are pretty great. Used as telephones, they can save us from bad situations and let us communicate while roaming freely, for the most part. Used as computers, they often become time-sucking black holes that can twist our sense of self and reality. Assuming they pick up when you call, phones are arguably a good thing for kids to have, especially since you can hardly find a payphone these days. But how do you teach kids to use them responsibly, so they can still become functioning adults and move out someday? [Jaychouu] believes the answer is inside of a specialized lockbox.

This slick-looking box has a solenoid lock inside that can be unlocked via a keypad, or remotely via the OBLOQ IoT module. [Jaychouu] added a few features that drive it out of Arduino lockbox territory. To prevent latchkey children from cheating the system and putting rocks (or nothing at all) in the box, there’s a digital weight sensor and an ultrasonic sensor that validate the credentials of the contents and compare them with known values.

Want a basic lockbox to keep your phone out of reach while you work? Here’s one with a countdown timer.

Superbly Synchronized Servos Swaying Softly

LEDs and blinky projects are great, and will likely never fade from our favor. But would you look at this sweeping beauty? This mesmerizing display is made from 36 micro servos with partial Popsicle sticks pasted on the arms. After seeing a huge display with 450 servos at an art museum, [Doug Domke] was inspired to make a scaled-down version.

What [Doug] didn’t scale down is the delightful visuals that simple servo motion can produce. The code produces a three-minute looping show that gets progressively more awesome, and you can stare at that after the break. Behind the pegboard, a single, hardworking Arduino Uno controls three 16-channel PWM controllers that sweep the servos. We like to imagine things other than Popsicle sticks swirling around, like little paper pinwheels, or maybe optical illusion wheels for people with strong stomachs.

You won’t see these in the video, but there are five ultrasonic sensors mounted face-up on the back of the pegboard. [Doug] has optional code built in to allow the servo sticks to follow hand movement. We hope he’ll upload a demo of that feature soon.

Servos can be hypnotic as well as helpful, as we saw in this 114-servo word clock.

Via Arduino blog

Air Hockey Table is a Breeze to Build

Many of us have considered buying an air hockey table, but are put off by the price. And even if the money is there, those things take up a lot of space. How often are you really going to use it?

This DIY air hockey table is the answer. It’s big enough to be fun, but small and light enough to easily stow away in the off-season. At ~$50, it’s a cheap build, provided you have a vacuum cleaner that can switch to blower mode. The strikers, goals, corner guards, and scoreboard enclosure are all 3D-printed, while the pucks and playfield are laser-cut acrylic. [Technovation] glued acrylic feet to the strikers to help them last longer.

The scoreboard is an Arduino Uno plus an LCD that changes color to match the current winner. Scoring must be entered manually with button presses, but we think it would be fairly easy to detect a puck in the goal with a force or weight sensor or something. For now, the RGB LEDs around the edge are controlled separately with a remote. The ultimate goal is to make the Arduino do it. Shoot past the break and cross-check it out.

Already have a table? Had it so long, no one will play you anymore? Build yourself a robotic opponent.

sprintf function

Description

This tutorial will help you to understand the sprintf function, and how to use it. Essentially, the sprintf function allows you to construct a string using a pre-formatted string template to which you can insert variables at pre-defined locations. The sprintf function will "compile" the string and assign it to a char array. All you have to do is make sure that the char array is large enough to hold all of the characters in the string. The best way to understand the sprintf function is with examples. And luckily, I have examples. What are we waiting for ? Let's dive in.

Parts Required: an Arduino and a USB cable.

 
 

sprintf ( char* array,   const char* strTemplate,   var1...);

 
 

Arduino IDE

While there are many Arduino IDE alternatives out there, I would recommend that you use the official Arduino IDE for this project. I used the official Arduino IDE app (v1.8.5) for Windows 10.
Make sure to get the most up-to-date version for your operating system here.


 
 

Arduino Code

The code below will show you how to use the sprintf function and includes a number of different format specifiers to play with. In each case the sprintf function writes to the "data" character array, and subsequently sends it through to the Serial monitor. The string template helps to construct the data output, allowing you to insert variables at specific locations within the text. The format of the variable is defined by the "format specifier" used in the sprintf function. The format specifier is always prefixed with a percentage sign (%).

 
 

Serial Monitor Output

  1. Upload the code to the Arduino.
  2. Open the Serial monitor in the Arduino IDE (Ctrl+Shift+M).
  3. Ensure that you have set the baud rate in the Serial monitor to 9600.
  4. You should see the following output:

 

The sprintf function requires that you have a character array to store the output. In the example code above, the output is stored in the "data" character array. It also requires a template that tells the function where to insert the variables. As you can see from the table below, the variables will be formatted based on the format specifier used. The format specifier can be quite useful for numeric conversions. Eg. decimal to hex conversions.

 
 

Format Specifiers

Some of the different format specifiers that can be used with the sprinf function are listed below.

Conclusion

Now that you know all about the sprintf function, I hope it will inspire you to use it in your own projects. Please let me know in the comments below how you use the sprintf function, and whether there was anything that you feel I failed to mention in this tutorial.
Happy Coding !!

 
 

If you found this tutorial helpful, please consider supporting me by buying me a virtual coffee/beer.

$3.00 AUD only
 

Social Media

You can find me on various social networks:

Follow me on Twitter: ScottC @ArduinoBasics.
I can also be found on Instagram, Pinterest, and YouTube.
And if all else fails, I have a server on Discord.


Universal Remote a Grove Infrared project


 
 

Description

This project will convert an ordinary Keyes infra-red (IR) remote
into a programmable universal remote.

 
A single button press on the Keyes remote will be converted into precise Sony IR signal combinations using an Arduino UNO and an assortment of Seeedstudio Grove modules.
You can assign signal combinations from more than one remote if desired.
An example combination could be to:
  • Turn on the TV and then switch channels.
  • Turn on the TV, sound system, and air-conditioner.
  • Turn up the volume x 3.
With only one button press of the Keyes remote, the entire cascade of Sony signals ensues. This project can be customised for other IR methodologies, however, you may have to modify the Arduino code to accommodate them.

 
 

Parts Required

  1. Arduino Uno (or compatible board)
  2. Grove Base Shield (v2)
  3. Grove Infrared Receiver
  4. Grove Infrared Emitter
  5. Grove Button
  6. Grove 16x2 LCD (White on Blue)
  7. Grove Universal 4 pin buckled cable: one supplied with each module.
  8. KEYES IR Remote Control
  9. SONY IR remote control
  10. USB cable - to power and program the Arduino
  11. Battery pack / Power bank

 
 

More information about the Grove modules can be found here:

**Please Note: The Grove Base shield has 14 pins on the Analog side, and 18 pins on the digital side. Check the number of pins on your Arduino UNO (or compatible board) to ensure the shield will sit nicely on top. NOT compatible with Arduino boards that have the Arduino Duemilanove pin header layout.

 
 

Arduino IDE

While there are many Arduino IDE alternatives out there, I would recommend that you use the official Arduino IDE for this project. I used the official Arduino IDE app (v1.8.5) for Windows 10.
Make sure to get the most up-to-date version for your operating system here.


 
 

Libraries required

The following libraries will be used in the Arduino code:

  1. Wire Library
  2. IRLib2 Library
  3. rgb_lcd Library

Wire Library

The Wire library is used for I2C communication for the Grove LCD screen and is built into the Arduino IDE - no additional download required for this library.
 

IRLib2 Library

The IRLib2 Library is actually a "set" of IR libraries, which can be downloaded from GitHub - here. In this project, I will be transmitting and receiving NEC and Sony IR remote signals.
The required libraries (within the set) will be:
  • IRLibRecv.h
  • IRLibDecodeBase.h
  • IRLibSendBase.h
  • IRLib_P01_NEC.h
  • IRLib_P02_Sony.h
  • IRLibCombo.h
Please see the IRLib2 GitHub Page for installation instructions.
 

rgb_lcd Library

The rgb_lcd.h library simplifies the operation of the LCD screen.
Download the rgb_lcd.h library from GitHub. Install the rgb_lcd.h library ZIP file into the Arduino IDE:
  1. Load the Arduino IDE
  2. Navigate to Sketch >Include library > Add .ZIP library...
  3. Select the downloaded zip file from GitHub, and press the "Open" button
  4. Check that it installed correctly by navigating to File > Examples > Grove-LCD RGB Backlight

 
 
 
 

Arduino Code

It is always best to upload the Arduino code to the board before you make any of the connections. This way you prevent the Arduino from sending current to a component accidentally. The code is available on my GitHub repository. Or you can have a look below. This code was written for an Arduino UNO, and may need to be modified if you are using a different board.

 
 
 
 

Connection instructions

If you are using the Grove Base Shield (v2). The connections are extremely simple. Use the following table as a guide. Please note that the code above assumes the following connections.
 

 

As per the table above, you would use a Grove universal 4-pin buckled cable and connect one side to D2 on the Grove base shield, and the other side would connect to the Grove Infrared Emitter.
D3 on the base shield would connect to the Grove Infrared Receiver, and so on.
You can connect the 16x2 LCD module to ANY of the four I2C connectors on the Grove base shield.

If you do not have a Grove Base shield, you have the option to use female-to-male jumper wires (together with a breadboard). But it is easier just to get the base shield and use the universal connectors.

 
 
 
 
 
 

Project Explained

When you apply power to the Arduino, the first thing that appears on the LCD screen is:
 


 
After pressing the Grove button (connected to D5), it displays the following message:
 

 
This is the cue to press and send a signal from the Keyes remote to the Infrared receiver (which is connected to D2). The Arduino will decode the Keyes remote signal, store the value in an array, and display the signal briefly on the LCD. The LCD should now show a message:
 

 
This message is a cue to press and send the FIRST signal from the Sony remote to the Infrared receiver. The Arduino will decode and store the Sony remote signal in a different array, and display it briefly on the LCD. You have the option to send a maximum of THREE Sony signal combinations to the Infrared receiver at this step in the process. The minimum number of Sony signals you can send is zero. The way to tell the Arduino that you do not want to send any further Sony signals to the receiver in this step, is by pressing the Grove Button (connected to D5).
 
The Arduino is programmed to receive a total of 5 Keyes signals, and each signal can be paired with a maximum of 3 Sony signal combinations. Once you have recorded all of the signal combinations, you will get a message:
 

 
The Arduino will now enter the final "Universal remote mode". In this mode, it will listen out for ANY of the 5 Keyes IR remote signals recorded previously, and will send the associated Sony signal combination in return. For example, if you press the number 1 on the Keyes remote, you could potentially have it so that the Arduino will transmit a Sony signal combination to turn on the TV and jump to a specific channnel.
 
The LCD will display each of the signals being transmitted. You will know you are in "Universal remote" mode because the LCD will display:
 

 
While you may be tempted to throw your Sony remote away at this stage (because you no longer have a use for it)... I would hold on to it just in case. The signals are not stored permanently. They disappear when the Arduino is powered off. But it doesn't have to be that way. You can easily modify the code to store it in eeprom memory or something.
 
That is not the only thing you can change.Technically, you could record the signal for any remote, however, you may need to include additional libraries or code to accommodate the alternate remote symbology. You can also modify the text messages on the LCD screen to make more sense to you. The LCD can only display 16 characters per row. So keep that it mind, when you come up with creative captions.
 
I would also like to mention the reason I chose not to use Seeedstudio's IR library, was because it took up too much memory. Their library probably accommodates for a wide range of symbologies. I chose the IRLib2 Library because I could select only the symbologies that I used (Sony and NEC). Thereby reducing the total amount of memory necessary to run the project. In fact, I have been finding that many of Seeedstudio's libraries to be very memory hungry. I originally wanted to create a gesture controlled remote. But the library combinations eliminated that possibility due to the cumulative memory requirements.
 
 
 
 

Conclusion

The IRLib2 library is the key to the success of this project. Without that library, this project would have been ten times harder. I was quite amazed by the effectiveness of this record / playback technique. It felt very weird to be operating my SONY TV with a cheap and nasty Keyes remote. It was quite surreal. While I chose to control my TV in this way, I could have just as easily recorded signals from one of my other remotes that use infrared signals. As more and more devices become controllable by remotes, the more I will consider turning this project into a permanent fixture in my house. A gesture controlled remote would have been nice, however, it looks like I will have to find some other use for that module now.

If you found this tutorial helpful, please consider supporting me by buying me a virtual coffee/beer.

$3.00 AUD only
 

Social Media

You can find me on various social networks:

Follow me on Twitter: ScottC @ArduinoBasics.
I can also be found on Instagram, Pinterest, and YouTube.
And if all else fails, I have a server on Discord.