Posts

Showing posts with the label PWM

Send HEX values to Arduino

Image
FIVE MINUTE TUTORIAL Project Description: Sending Hex values to an Arduino UNO This simple tutorial will show you how to send Hexadecimal values from a computer to an Arduino Uno. The "Processing" programming language will be used to send the HEX values from the computer when a mouse button is pressed. The Arduino will use these values to adjust the brightness of an LED.   Learning Objectives To Send Hexadecimal (Hex) values from a computer to the Arduino Trigger an action based on the press of a mouse button Learn to create a simple Computer to Arduino interface Use Arduino's PWM capabilities to adjust brightness of an LED Learn to use Arduino's analogWrite() function Create a simple LED circuit...

NPN Transistor Sketch (P2N2222AG) using PWM

Image
We are now going to build a simple circuit to test out the P2N2222AG transistor in the sparkfun inventor's kit . You can also buy this transistor from RS-online . Here are the components that you will need. 1 x Arduino UNO 1 x Breadboard 1 x P2N2222AG transistor 3 x LEDs  (1 x Red LED, 2 x Yellow LEDs) 3 x 330 ohm Resistors Wires to connect it all together. Here is the Fritzing sketch: We will use Pulse width modulation (PWM) to fade the LEDs in and out.  Load the "Fading" example into the Arduino. ( File>Examples>Analog>Fading) I used this sketch to help me understand how electricity flowed through the transistor by disconnecting a wire here and there. I am not sure if this is advisable, so do this at your own risk. If you are an electrical engineer, feel free to comment. Please let me know if this is "risky" business. I have had no formal training in electronics, so don't blame me if your arduino, or transistor blows up ! But from what I underst...

Arduino UNO: LED Sensor, Part One

Image
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 ...