Physical Pixel using Arduino

Summary of Physical Pixel using Arduino


This project demonstrates using an Arduino board to control an LED via serial communication. When the Arduino receives the character 'H' from the computer, it turns on the LED connected to pin 13; receiving 'L' turns the LED off. Data can be transmitted from the Arduino serial monitor or programs like Processing, Max/MSP, Flash, or PD. The setup requires connecting an LED to pin 13 and ground, with the option to use the Arduino's built-in LED. The Arduino code listens for serial input and switches the LED state accordingly.

Parts used in the Physical Pixel project:

  • Arduino Board
  • LED (connected to pin 13)
  • Resistor (recommended but not explicitly mentioned, typically 220Ω for LED protection)
  • Connecting wires
  • Breadboard (optional for prototyping)

This example example uses the Arduino board to receive data from the computer. The Arduino boards turns on an LED when it receives the character ‘H’, and turns off the LED when it receives the character ‘L’.

Physical Pixel using Arduino

The data can be sent from the Arduino serial monitor, or another program like Processing (see code below), Flash (via a serial-net proxy), PD, or Max/MSP.

Software Required

Circuit

Attach an LED to pin 13. The long leg, or anode, goes to pin 13. The short leg, or cathode, goes to ground. You can also use the built-in LED on most Arduino boards.

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Schematic

Physical Pixel using Arduino schematic

Code

/*
Physical Pixel
An example of using the Arduino board to receive data from the
computer.  In this case, the Arduino boards turns on an LED when
it receives the character ‘H’, and turns off the LED when it
receives the character ‘L’.
The data can be sent from the Arduino serial monitor, or another
program like Processing (see code below), Flash (via a serial-net
proxy), PD, or Max/MSP.
The circuit:
* LED connected from digital pin 13 to ground
created 2006
by David A. Mellis
modified 30 Aug 2011
by Tom Igoe and Scott Fitzgerald
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/PhysicalPixel
*/
const int ledPin = 13; // the pin that the LED is attached to
int incomingByte;      // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// see if there’s incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it’s a capital H (ASCII 72), turn on the LED:
if (incomingByte == ‘H’) {
digitalWrite(ledPin, HIGH);
}
// if it’s an L (ASCII 76) turn off the LED:
if (incomingByte == ‘L’) {
digitalWrite(ledPin, LOW);
}
}
}
Major Components in Project

Hardware Required

  • Arduino Board
  • Analog Sensor (potentiometer, photocell, FSR, etc.)

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top