In this project, I have connected an Arduino to my computer and used a photoresistor to control an animation on the screen. Other sensors could have been used, but I chose a photoresistor because it feels like magic!!
The photoresistor responds to changes in ambient light as my hand moves up and down. The Arduino sends the reading to a Processing sketch on the computer via a Serial command (through the USB cable). The processing sketch interprets the signal from the Arduino and selects the appropriate picture to display.
I took a series of screenshots from the following YouTube video: http://www.youtube.com/watch?v=h6nE8m74kDg And after borrowing a bit of code from these sites (1,2), the project was born. This idea is not new, nor my own. There are many people who have done this project before, but I thought to blog about how I have done it, just for fun.
The Project Movie
Components Required
Arduino Uno (and associated software), and USB cable
//auto-adjust the minimum and maximum limits in real time if(minLight>lightLevel){ minLight=lightLevel; } if(maxLight<lightLevel){ maxLight=lightLevel; }
//Map the light level to produce a result between 1 and 28. adjustedLightLevel = map(lightLevel, (minLight+20), (maxLight-20), 1, 28); adjustedLightLevel = constrain (adjustedLightLevel, 1,28);
/*Only send a new value to the Serial Port if the adjustedLightLevel value changes.*/ if(oldLightLevel==adjustedLightLevel){ //do nothing if the old value and the new value are the same. }else{ //Update the oldLightLevel value for the next round oldLightLevel=adjustedLightLevel;
/*Send the adjusted Light level result to Serial port (processing)*/ Serial.println(adjustedLightLevel); } }
import processing.serial.*; Serial myPort; String sensorReading="";
// Create the array that will hold the images PImage[] movieImage = new PImage[29];
/* The frame variable is used to control which image is displayed */ int frame = 1;
/* Setup the size of the window. Initialise serial communication with Arduino and pre-load the images to be displayed later on. This is done only once. I am using COM6 on my computer, you may need replace this value with your active COM port being used by the Arduino.*/
void setup(){ size(700,600);
myPort = new Serial(this, "COM6", 9600); myPort.bufferUntil('\n');
Have you ever wondered if there was a way to store and retrieve data from a USB stick with an Arduino UNO? Most people choose SD cards to store their project data, but you may be surprised there IS a way! IC Station have a nice little module which allows you store and retrieve your Arduino (or other MCU) project data to a USB stick. I am not too sure why USB storage is not widely used in Arduino projects? These modules are not expensive, they have been around for quite a while, and are relatively simple to use. You do not need any libraries to get them to work, however, I must say that documentation for this module is not that easy to find. This site and this document proved to be very useful in my endevour to get this module working, and I hope my tutorial below will help you get started and bridge some of the information gaps. The...
Introduction Nextion is a programmable human machine interface (HMI) that can be customized and designed to simplify the interaction between you and your project. This Nextion Enhanced module (NX4827K043) with a resistive touch screen display, has some additional features not seen in previous traditional versions of the Nextion series. A built in real time clock (RTC) Accessible flash memory (32MB) GPIO functionality Faster clock speed Before you connect the Nextion Enhanced module to your project, you need to design your interface with the free Nextion Editor. The editor can be downloaded here. In this project, I will be designing a simple dynamic interface, which will allow me to interact with a stepper motor in two different ways. The first interface will let me control the direction and speed of the stepper motor through the use of a simple GUI. I will have left and right arrows for the direction, and up and down arrows for the speed. I will also map the Expansion board...
PART THREE If you happened to land on this page and missed PART ONE , and PART TWO , I would advise you go back and read those sections first. This is what you'll find in partone : Downloading and setting up the Android SDK Downloading the Processing IDE Setting up and preparing the Android device Running through a couple of Processing/Android sketches on an Andoid phone. This is what you will find in part two : Introducing Toasts (display messages) Looking out for BluetoothDevices using BroadcastReceivers Getting useful information from a discovered Bluetooth device Connecting to a Bluetooth Device An Arduino Bluetooth Sketch that can be used in this tutorial InputStream and OutputStream We will now borrow some code from the Android developers site to help us to establish communication between the Android phone and the Bluetooth shield on the Arduino. By this stage we have already scanned and discovered the bluetooth device and made a successful connection. We now need to create ...
Comments
Post a Comment