- Get link
- X
- Other Apps
Posts
Showing posts from June, 2011
Arduino UNO: PhotoCell - sensing light
- Get link
- X
- Other Apps
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3iR212N_72mqPx8XGLsgz7MygGdtvND3HGF3yPUbfBaLhb8fj2l9UsfFrM_r_j3PhJOCDsnSpmwoG9q7GukC6z5C9GF1N19yDtTa1uA-5fmcvve9ufJb2ioF9i8fY3cytpOIOsk2pOR4/s1600/Photocell+only.jpg)
In this tutorial, we will send the analog readings obtained from a Photo Resistor, also known as a Light Dependent Resistor (LDR), to the computer. We will display the each reading on the monitor using a simple Processing sketch. Here is what you will need to complete the Arduino side of the project: Parts Required: PhotoCell (or PhotoResistor) 10K resistor Breadboard Arduino UNO 3-4 wires(to connect it all together) USB cable to upload sketch and for Serial communication with Processing . Fritzing sketch: Arduino Sketch 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 /* ========================================================== Project : Send Photo resistor values to computer Author: ScottC Created: 25th June 2011 Description: This sketch will ma...
Displaying Serial data from an Arduino UNO on your computer screen - using Processing
- Get link
- X
- Other Apps
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjylTlvDJKJIYZcK7OHyJ57ucPeFXq1kOq7DxIk-Fr6ytdPAHKXZE50pkSDd42WKjqRkrv-bdk3UdJ70WPzSTdtAV6zt32WDS06a4b0R-8uanIQNes1BPAggobXWykv2Mwm7LF_k6oOr_8/s320/Sensor+Reading.jpg)
Here is a very basic Processing Sketch that will allow you to receive data from the Serial port attached to the Arduino and display the reading on your computer screen. In my case, the Arduino is connected to COM13. You may need to change this if you decide to follow in my footsteps. You will need to setup an Arduino sketch to send serial data to the computer using a Serial.println(value) command. The processing sketch will look for the line feed character ' \n' coming from COM13, which will trigger a serialEvent(). You can get processing to look for another character if you want to: just change the character within the bufferUntil() command. The draw() method is made redundant because the screen updating is handled by the serialEvent() in response to serial data communication with the Arduino UNO Here is the Processing sketch code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 import processing.serial.*; Serial my...
Reading a text or CSV file using the Processing language
- Get link
- X
- Other Apps
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiv8zzZwGeCXiOdwotMp6W2wHP4Nor7eTF3gAP93eJP6Ui5BCVt9t8uYi3Wajt0k8q9935c_ixiOU6hVfQWoVboFxUo9BwtdtP2_mFBTGcepB0wr9S25O2VVwZej2WqBpLW7GX50qd9BMA/s320/Text_file_to_Import.jpg)
In a previous post , I showed you how to export data to a text file. Now I will show you how to import it back into your Processing program. This will come in handy later on. This is what my data looks like in the text file: There are many ways to import text from a text file, and there are many ways to store the data within your code after you have imported it. Feel free to make mention of your method in the comments, however, this one definitely works, and is doing what I want it to do. I have decided to store each line within an ArrayList . The first column is stored in another ArrayList by splitting the data into bits using splitTokens . Most of the file reading code was taken from this Java site , and seems to work quite fine with the Processing programming language . I have taken bits and pieces of code from various places, and added my own flavour. Here is a snippet of the data after import. ...
Colour Sensing - Update Two
- Get link
- X
- Other Apps
This colour sensing project is starting to get bigger than I wanted it to. However, I am learning a lot about the Arduino/Processing as I look for ways to accomplish my tasks. When you see my final code, I will have a bit of explaining to do. I now have a relatively quick method of detecting MegaBlok colours, and will probably use a PhotoCell to improve read rates under different lighting conditions. Once I have done this, I would like to get the Arduino to do something in response to the colour. But let me get over step one.
How to append text to a txt file using Processing
- Get link
- X
- Other Apps
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1HeAmHwr6NL3bwQbraqJXYx8SCEfxyDMlvev62bAu8zJFIbsnMsMk0C-yjb_DaHGBhMGxlIsd6C7l_N7KxE2eiitDO7oTA2IRE8d38qXXn11rlsaK8cD1_TfnPKejQMJ2-8nehAJlLtc/s1600/Separator.jpg)
Sometimes it would be useful to have a function to save data to a text file. I plan to save some of my Arduino sensor data to a text file using the Processing language . Ninety percent of the following code comes from this forum posting . Thank goodness for the internet, and for people like PhiLho and Cedric. I modified their code and ended up with this (to suit my own project): Processing Sketch 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 /* ===================================================================== Project : Append data to a text file Author : ScottC Created : 16 Nov 2011 (Updated 26 Aug 2014) Description : Use the Processi...
Colour Sensing - Update One
- Get link
- X
- Other Apps
I successfully modified the previous sketch to detect the colour of the Mega Blok that was over the sensors. However, it was taking up to 10-20 seconds to reveal the answer. The problem I am experiencing is mainly due to the effect of ambient light levels. Just when I get all my limits set up, something changes, and I lose the ability to identify one of the Bloks. I get the feeling that I may have over-complicated the design or the method to detect the Blok colour, and am now trying to simplify and speed up the process. Once again, I think I may be able to get faster results using a PhotoCell, but I don't want to differentiate by light level alone. I would like to read colour using one or more LEDs as a Sensor. I think I need to utilise the RGB LED functionality a little bit more. So instead of white light, I might scan with different colours. Stay tuned. If you have any ideas, please make suggestions in the comments.
Colour Sensing - Intro
- Get link
- X
- Other Apps
Now that I have different patterns for the different coloured Mega Bloks, I will try to get processing to "Identify" or tell me which Blok is which. I am essentially trying to make a DIY colour sensor. I know that if I get the RGB LED to produce different coloured light (rather than just white), I will be able to get more information/patterns from my Red and Yellow LED sensors, however, I think I have enough information from the white light to tell the difference between the Red, the yellow and the green Mega Bloks. We'll see how we go. Stay tuned. For more information about what project I referring to - jump to this Blog Posting: Arduino UNO: LED Sensor Part Two
Arduino UNO: LED Sensor, Part Two
- Get link
- X
- Other Apps
Building on the last project, I am now using a Red and a Yellow LED as a Sensor to detect light coming from an RGB LED. Putting different coloured Mega Bloks over the LEDs has different effects on the Sensors as the RGB LED gets brighter and brighter. I used the Processing Language to control the brightness of the RGB LED through a Serial command, and then use the resulting Sensor readings from the Yellow and the Red LEDs to create a chart or plot. Here are the results of my experiment. Red Mega Blok Yellow Mega Blok Green Mega Blok When the displayed bars are RED, it indicates that the Red LED is absorbing MORE light than the Yellow LED (and vice versa). Hence this is a "Difference Chart". The Green Mega Blok absorbs more Red Light than the other blocks, therefore producing a big difference between Red LED sensor readings and Yellow Sensor readings. Here is the list of components required to perform this experiment Arduino UNO Breadboard 1 x Red LED 1 x Yellow LED 1 x RGB LE...
Arduino UNO: LED Sensor, Part One
- Get link
- X
- Other Apps
As seen in the previous blog postings, the LED (Light Emitting Diode) was used to DISPLAY the result of various sensors. It was also used to create a variety of Light patterns or sequences. The LED is commonly used as an OUTPUT device, however, I have since found out: there is another option. You can use the LED as an INPUT device !! I have only tried this with a Yellow LED and a Red LED, however, this should work with any colour. Some sites recommend using a clear/transparent/colourless LED for best effect, but it depends on what you are trying to achieve. The LED responds better to light of the same wavelength that it emits. So a yellow LED responds better to yellow light, and a red LED responds better to Red light. The following experiment attempts to prove this theory. A Red and Yellow LED alternate and fade in to maximum brightness using PWM (Analog Output). Meanwhile, a separate LED is used as an INPUT device to receive the light. The value obtained is plotted using a processing ...