Final Project- Motion Sensor Tie


ALS_Blog_LogoMotion Sensor Tie

what is this project? This is a project that involve 2 bracelet and 2 persons team project. One part of the project is design as the input and the other part of the bracelet is output.My original design of the project is one person wearing bracelet on their arm, has an Adafruit flora, a motion sensor (flora accelerometer) and jumper wire and the other person arm would have led light, however we change it led light will be put inside of a tie and glove will have inside the accelerometer and the flora mainboard. When one teammate with the motion sensor tilt his/her arm(glove), the other teammate would wear a tie that would be output for led light display.

This project is a different for various reason first the name is different, second the older project was bracelets and they use processor. We use a glove and inserted the accelerometer and flora atmega and put RGB led light inside of a tie. The original project the designer use processor and code to make the led light go around in a circle however in my project the led light is program to random and we are only using arduino software.

Material needed

jumper wire red,yellow and black, wire stripper, wire cutterusb cable, a tie and glove (any of your choice), a hot gun, tape, a knife (look at collage below for more details and visual image)

  • Microcontroller/main device

Adafruit flora v1.0a with Atmega32u4 chip (micro processor)  

  • Input devices                                                                  

Adaruit Flora accelerometer/compass sensor   version lsm 303 DLHC

  • Output device

Adafruit Flora RGB NeoPixel v2 in this project use only 6

project name is formally known as motion light sensor change to Motion Sensor Tie

unnamed (1)

3D paper image of the project                         Project  develop that we was going to use:

  unnamed                     download bracelet

we change our project to a tie and glove presentation because we ran out of time to purchase two bracelets.

Testing the adafruit flora mainboard and adafruit flora RGB Neo Pixel v2  and Adaruit Flora accelerometer/compass sensor using alligator cables. The adafruit floara neo pixel is very bright

Step 1: Research details on materials to develop this project

Adafruit flora1.0a Atmega32u4 chip is similar to arduino uno but it is designed as wearable electronics platform and small enough to put anywhere for creative interactions. The device use microprocessor called Atmega32u4. Flora is 1.75 diameter.Flora mainboard is the main piece of the puzzle to make this project come to life. It has large pads to connect premium stainless steel thread. The pad are layout to make it easy to connect flora various components like sensors, ultimate gps, motion sensor (accelerometer/compass), flora light sensor ir+visible lux sensor or flora led neopixel. Flora has built in usb HID support and can act act like a keyboard or mouse. Flora is perfect for designing your own expressive and functional electronic fashion Arduino software v1.0.5 has included flora driver, libraries and examples. This version of flora use mini b connector.


   Quick Breakdown

small reset button to reset the system

one side of the board is used for input like for example the accelerometer (type of sensor) will go onto the side label scl/sda/gnd/3.3v/

the other label 3.3v/d10/d6/d9 use for output like the flora RGB neopixel (type of actuator)

Ground (no power). there is 2 GNDs for a reason

Simple connector last PWM  SCI (clockline) is the i2c clock pin – its required to talk to the acelerometer
Pulse Width Modulation (PWM) rapidly change the output pin high to low over fixed period of time depending on how the code is design.On flora main board D9, D10, D6 are pwn pins

Digital pins is use for connection of the flora RGB neopixel

Serial data analyzer SDA (data line) is the i2c data pin – its required to talk to the accelerometer

Scl and sda are like brother and sister. It is used to communicate with 12c/ two wire interface (twi) device like for example lcd screens

Rx and Tx- Recieve data and Transfer data to serial monitor using code

void setup()                    // run once, when the sketch starts
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Hello world!");  // prints hello with ending line break 

3.3 volt: pulls current of 100mA max to the board

Vbatt: is used when you want to power something like Neopixels or a servo, a device that require more than the 150mA available from the on board regular.

flora is mainly powered through jst connector (usb connection). JST input (button) (on&off switch) is polarity protected. Vbatt control by using data Rx and Tx for motion sensors different type of control of power. Do not use vbatt as an input because it might damage your battery if you also plug in the usb connector to a computer.

Important note for beginner

It is difficult to destroy the Adafruit flora v1.0a (Atmega32u4) by connecting a battery backward polarized connectors and protection diodes. The power supply designed to be flexible. flora is fabric friendly. There is 2 on board japan solder less terminal connectors with protection diodes for the external battery packs from 3.5v to 9v DC. It can run on 3v but 3.5v-5v or higher if you trying to add something more powerful. In addition, can use Lilon/LiPoly, LiFe, Alkaline or rechargeable NiMh/NiCad batteries of any size. for more information visit

Definitions: Japan solder less terminal (jst) battery connector is white electrical connectors mounted onto the printed circuit board (pcb) (flora).

polarized:restrict the vibration of transverse wave or partially to one direction

The accelerometer and flora mainboard has a 12C (sda/scl) interface it is also known as 12c bus used to interact with real-time clocks, digital potentiometers, temperature sensors, digital compasses, memory chips, FM radio circuits, I/O expanders, LCD controllers, amplifiers

on arduino uno the 12C Bus is analogs A4(SDA) and A5(SCL)

Please note: must download the drivers and specific libraries. when first plug in the flora mainboard make sure serial port and board is adafruit flora is correct. 

download the arduino ide v1.05 software with flora installed not the new verizon v1.06 why? Because it does not have flora board installed.

analysis this pdf for steps to install driver because for windows the serial port would not work properly unless the driver was installed correctly

steps to install a library on windows, mac, linux

websites to download the libraries
adafruit accelerometer
adafruit neopixel

In addition when plug in mini usb the circuit will light up green. Before uploading any code whether it manually structured or an example from arduino built in verify for any error in the code then upload to the code to the board. When the code upload the board when light up red and will see Transfer data (Tx) and recieve (Rx) data light flicker on.

For insurance that the adafruit flora mainboard working properly input the code into arduino software and plug in the flora check the serial port and board is correct then upload the program to flora. you should see on board blinking led.

  1. // Pin D7 has an LED connected on FLORA .
  2. // give it a name:
  3. int led = 7;
  5. // the setup routine runs once when you press reset:
  6. void setup() {
  7. // initialize the digital pin as an output.
  8. pinMode(led, OUTPUT);
  9. }
  11. // the loop routine runs over and over again forever:
  12. void loop() {
  13. digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
  14. delay(1000); // wait for a second
  15. digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
  16. delay(1000); // wait for a second
  17. }


6 standtest to test flora neopixel

Step 2: connection and layout


Adafruit flora mainboard connect to adaruit flora accelerometer/compass sensor 4 connections

mainboard (GND) jumper wire connect to accelerometer (GND)

mainboard (scl) jumper wire connect to accelerometer (scl)

mainboard (sda) jumper wire connect to accelerometer (sda)

mainboard (3.3v) jumper wire connect to accelerometer (3.3v)

Adafruit flora mainboard connect to adaruit flora RGB Neo Pixel v2 3 connections

Adafruit flora mainboard (Vbatt) jumper wire connect to flora RGB Neo (+)

Adafruit flora mainboard (D6) jumper wire connect to flora RGB Neo (arrow pointing toward led light)

Adafruit flora mainboard (GND) jumper wire connect to flora RGB Neo(bottom of led light)

wire connection

Red wire for power (+)

Black wire for Ground (gnd)( – )

Yellow wire for signal (–>)

Adaruit flora RGB Neo Pixel v2 3 connections

PLEASE NOTE: connection the RGB Neo led lights depend on how many led you will be using for your project. For more infomation visit diagram below good exampleflora_PB282306

 Step 3: The code, toubleshooting & debug=successful project

key note the code has to match with the circuit. for example: on the flora you connect the flora RGB led lights to D6 then in the code it has to be D6. move_thershold number was change because the higher the higher the number the lower the sensitivity in the accelerometer.

  • Motion Sensor Tie code

#include <Wire.h>                              //library to connect TWI/12c like sda/scl on the board
#include <Adafruit_LSM303.h>      //library for accelerometer/motion sensor
#include <Adafruit_NeoPixel.h>     //library for flora neopixel

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_RGB Pixels are wired for RGB bitstream
// NEO_GRB Pixels are wired for GRB bitstream
// NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels)
// NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(6, 12, NEO_GRB + NEO_KHZ800);

//set neopixel to D12 on the flora mainboard
Adafruit_LSM303 lsm;

// Here is where you can put in your favorite colors that will appear!
// just add new {nnn, nnn, nnn}, lines. They will be picked out randomly
//R    G    B
unit8_t myFavoriteColors[][3] = {{200, 0, 200}, // purple
{200, 0, 0}, // red
{200, 200, 200}, // white
{ 0, 200, 0}, // green
{ 0, 0, 200}, // blue
// don’t edit the line below
#define FAVCOLORS sizeof(myFavoriteColors) / 3

// mess with this number to adjust TWINklitude 🙂
// lower number = more sensitive

void setup()                          //set up the program to do specific action
Serial.begin(9600);           //command serial monitor to activate

// Try to initialize and warn if we couldn’t detect the chip
if (!lsm.begin())                    //if library is detect start serial monitor
Serial.println(“Oops … unable to initialize the LSM303. Check your wiring!”);
while (1);                //if library not detected go to turn off strips
strip.begin();         //; // Initialize all pixels to ‘off’

void loop()                    //if the accelerometer library is detected continue on to void loop
// Take a reading of accellerometer data;
Serial.print(“Accel X: “); Serial.print(lsm.accelData.x); Serial.print(” “);
Serial.print(“Y: “); Serial.print(lsm.accelData.y); Serial.print(” “);
Serial.print(“Z: “); Serial.print(lsm.accelData.z); Serial.print(” “);

// Get the magnitude (length) of the 3 axis vector
double storedVector = lsm.accelData.x*lsm.accelData.x;
storedVector += lsm.accelData.y*lsm.accelData.y;
storedVector += lsm.accelData.z*lsm.accelData.z;
storedVector = sqrt(storedVector);
Serial.print(“Len: “); Serial.println(storedVector);

// wait a bit

// get new data!;                  //Retrieve Rx and Transfer new data
double newVector = lsm.accelData.x*lsm.accelData.x;
newVector += lsm.accelData.y*lsm.accelData.y;
newVector += lsm.accelData.z*lsm.accelData.z;
newVector = sqrt(newVector);
Serial.print(“New Len: “); Serial.println(newVector);

// are we moving
if (abs(newVector – storedVector) > MOVE_THRESHOLD) {
flashRandom(5, 1); // first number is ‘wait’ delay, shorter num == shorter twinkle
flashRandom(5, 3); // second number is how many neopixels to simultaneously light up
flashRandom(5, 2);

void flashRandom(int wait, uint8_t howmany) {

for(uint16_t i=0; i<howmany; i++) {
// pick a random favorite color!
int c = random(FAVCOLORS);              //different variable for different colors
int red = myFavoriteColors[c][0];
int green = myFavoriteColors[c][1];
int blue = myFavoriteColors[c][2];

// get a random pixel from the list
int j = random(strip.numPixels());
//Serial.print(“Lighting up “); Serial.println(j);

// now we will ‘fade’ it in 5 steps
for (int x=0; x < 5; x++) {
int r = red * (x+1); r /= 5;
int g = green * (x+1); g /= 5;
int b = blue * (x+1); b /= 5;

strip.setPixelColor(j, strip.Color(r, g, b));;
// & fade out in 5 steps
for (int x=5; x >= 0; x–) {            //set the direction of digital pins
int r = red * x; r /= 5;
int g = green * x; g /= 5;
int b = blue * x; b /= 5;

strip.setPixelColor(j, strip.Color(r, g, b));;
// LEDs will be off when done (they are faded to 0)

Once code is upload to flora and the device is properly connected. Open the serial monitor to see accelerometer working with movement. Also in the code it is program to send signal to serial monitor.


Issue and troubleshooting why?

I wanted to connected six RGB LED light and the code wasn’t working. me and my team partner decide to take apart the project and start over just to make sure the connection is secure first and then work on the code.

When I connected all six neopixels together and tested on a strand test they all worked fine. When switched to the code that uses the accelorometer only two pixels light up. When I checked the volts they were all working fine. They worked according to the strandtest. So I took off two NeoPixels making it down to four and the strand test worked.

I wanted to connected six RGB LED light and the code wasn’t working. me and my team partner decide to take apart the project and start over just to make sure the connection is secure first and then work on the code.

me and my team partner had  a weak connection when we decide to strip the jumper wire and tie them to the components. it show that it was a shortage in the pixels communication.

Multimeter Testing:


all issue was resolve when we soldered all components. It is a very secure connection. Further analysis the code to make sure it match the connection and as a result it was a successful project.

New project have red glove with flora mainboard and accelerometer hot gun with tape

The tie has 6 flora neopixel hot gun in with tape and red,yellow and black jumper wire soldered on to maintain great connection no shortage.

unnamed (1)

fun fact section

The software and devices is compatible with Mac, Linux and windows

For different connections can also use conductive fabric, conductive paint, alligator clips

For different type of micro controller boards similar to Arduino and Flora there is mainboard called lilypad, gemma and trinket


Tinkercad, Huh? What that?

What is tinkercad? Tinkercad is website that allow you to design three dimensional shapes or objects for 3 dimensional printing. Once you created your design you can send to the printer to develop it into actual shape. This is similar to having a personal computer at home and hp printer. Depending on what you would like the 3D printer to print from any compatible website like tinkercad, shapeway, thingiverse etc and the type of printer you have will determine how long it will take to print. Referring back to my hp printer example in order for hp printer to work it would need hp software installed on your personal computer which is same thing as need the website to use the 3D printer. A technician would say if you want to components to talk to each other, you would have to get the components to communicate to each other.  There are different types of three dimensional printer range from beginners level to advance level. In the spring of 2014, I did a paper on three dimensional printing because I became fascinated with the website and the three dimensional printer results. The product does have negative and positive impact on society but in this day and age what doesn’t.There was a story on CNN news that take about a company from Texas use their three dimensional printer to make guns. Many businesses invested in the product to reduce expenses, individual brought 3D printer to make and sell various things on ebay and amazon, in addition bio engineers designed bio printing a three dimensional printer that prints new organs or blood vessels for people in need. I feel 3D print is very innovative and will continue to grow into popular investment for business to save money.

Screen Shot 2014-11-11 at 2.22.58 PM




unnamed (2)

Part 3: Arduino Projects

In the arduino project book I will be doing project number 4 and 5. The 1st  project is called color mixing lamp. In the book it says this project take approximately 45 minutes to complete. For me it may have taken me about an hour because I would add another 15 minutes to set up and how i would like to wire the circuit. A new idea that I have tried when dealing with arduino is get piece of paper and pen and write out detail for detail how the curcuit board and arduino uno going to be wired. I have done this because with previous project I have encounter issues and i thought it was good idea for troubleshooting. Make sure on the arduino software in the tools tab the serial port is correct and board is correct.

The materials needs for this project would include:

220 OHM Resistors (3)                                        10 KILOHMS Resistors (3)

RGB LED has 4 legs                                            13 jumper wire

Photoresistors (3)                                                   Breadboard

Arduino Uno                                                             red green blue gels

rbg led  Photoresistorresistor

The purpose of this project is to use red green blue tri color led, photoresisor and red green or blue gels to fade the leds to the specific colors (color mixing lamp). For example, using an green gel on photoresistor the RGB led should display color green.

I will explain the role of each component on the circuit board to make this happen.On the arduino uno you can see next to pin number digital (PWM~).Pulse Width Modulation (PMW) can be used to fade leds. PMW turn the output pins high or low like change lights on and off. The percentage of time a pin is high in a period it called duty cycle. A lower duty cycle will give dimmer LED than higher duty cycle. The arduino uno has 6 pins set aside for PMW (digital pins 3,5,6,10,11). Notice the ~ symbol next to each pin. Photoresistors are sensors (input) they change resistance depending on the amount of light that hit the sensor. On the board 3 photoresistor connect one side  to power and another side to 10 kilohms resistor that would go to ground.

The resistor along with photoresistor form a voltage provider; the voltage at the point where they meet is proportional to the ratio of their resistance. when resistance change of the photoresistor changes when light it so would voltage, it is rule of ohm’s laws. In addition along side resistor are 3 jumper wire connected to analog in pins 0-2. Each analog is coded for a specific color like green over photoresistor connected to analog 1 or A1.

The most interesting component on the circuit board is 4 leg RGB LED. First I would like you to note that 3 220 ohms resistor are connected to 3 pwm pins 9-11 because they determine how much voltage the RGB led should receive out of 5 voltage. It has a red green and blue element inside plus a leg for ground (the cathode).

Color Mixing Lamp Code

//declare the RGB led, the value never change
const int greenLEDPin = 9;
const int redLEDPin = 11;
const int blueLEDPin = 10;

//link input and output
const int redSensorPin = A0;
const int greenSensorPin = A1;
const int blueSensorPin = A2;

//add variable for incoming sensor value and for the output of value when using fade
//declare variables
int redValue = 0;
int greenValue = 0;
int blueValue = 0;

int redSensorValue = 0;
int greenSensorValue = 0;
int blueSensorValue = 0;

//begins communication between board and pc
void setup (){
pinMode(greenLEDPin, OUTPUT); //define led pins as output
pinMode(redLEDPin, OUTPUT);
pinMode(blueLEDPin, OUTPUT);
void loop(){
//read the value of each light sensor
//analogRead store the value in appropriate variable with ADC
redSensorValue = analogRead(redSensorPin);
delay(5); //take analog digital converter a millisecond to read each sensor
greenSensorValue = analogRead(greenSensorPin);
blueSensorValue = analogRead(blueSensorPin);

//print values onto serial monitor on pc
Serial.print(“Raw Sensor Value \t Red: “); //\t is like tab key on keyboard
Serial.print(“\t Green: “);
Serial.print(“\t Blue; “);
redValue = redSensorValue/4;
greenValue = greenSensorValue/4;
blueValue = blueSensorValue/4;
Serial.print(“mapped Sensor Value \t Red: “);
Serial.print(“\t Green: “);
Serial.print(“\t blue: “);
//the function to change 4 leg led brightness (pwm) is analogwrite
analogWrite (redLEDPin, redValue);
analogWrite (greenLEDPin, greenValue);
analogWrite (blueLEDPin, blueValue);


Part 2 Project 5 Mood Cue

This project uses a new component called servo motor. The objective is to design servo motor to rotate motor arm by turn the potentiometer. It is suppose to determine what would you are in today.I think it detect I was in bad mood because mines did not work completely.According to the book this project take a hour to complete. There are a lot of few new materials I will be using this project. The materials include:

Potentiometer                    100UF Capacitor (2)

Servo Motor                        Male header Pins (3)

Motor Arm                          Jumper wire (8)

all materialsP5

mini details of servo motor

Servo motors are special motors that only spin around 180 degree not a full circle. Servo motor has a certain number of pulses that tell them what angle to move to. The pulses always come at the same time intervals, but the width varies between 1000 to 2000 microseconds. Arduino software come with library that allow you easily control the motor.Servo only rotate 180 degrees and your analog input goes 0-1023. Use the function map() to change scale values coming from the potentiometer.

The set up process

The circuit board is first connected to jumper cables of 5 voltage and ground.  There is a 100uf capacitor in front of the potentiometer. Capacitor role is to store and release electrical energy in circuit. The potentiometer is a voltage divider. It has 3 pins, 1 pin connect to ground, middle pin connect to analog in and last pin connect to power. When turn the knob it will change the voltage between analog pin and power. NOTE: potentiometer is two piece component that has to be put together, the knob and 3 pin piece is separate.

The servo motor has 3 wires. red wire for power,black wire for ground and white wire for control or pin ~9. Note: the servo motor has female connectors and you would need to use 3 male connectors for this circuit. In addition the motor arm would have to be placed on the servo motor. When servo motor start to move it will draw more current than if it was in motion. Placing 100uf capacitor across power and ground next to male connectors it will balance out voltage on the circuit. The servo motor is using pwm pin and it is converted using analog digital converter A0.

The Mood cue code

#include <Servo.h>                      //new library because new feature and has to be declared

Servo myServo;                         //declare the object servo 

//declare variable

//set up named constant for the pin the potentiometer attached to and variable to hold the analog input value

int const potPin = A0;

int potVal;

int angle;
void setup(){                                      //servo is attach to pin 9
Serial.begin(9600);                    //serial connection the value can be checked on pc everytime turn potentimeter
void loop(){                                 //read analog input and print out the value to the serial monitor
potVal = analogRead(potPin);
Serial.print(“potVal: “);
angle = map(potVal, 0, 1023, 0, 179);
Serial.print(“, angle: “);

Part 2-Quiz

1.)What is Arduino?

Arduino is electronic prototype platform that was design for artists and designer to add interactivity to their project. Arduino is a microcontroller microcontroller board based on the ATmega328(datasheet). Microcontroller if you do not know is is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Program memory in the form of NOR flash or OTP ROM. There are many different types of Arduino’s. The recommended for beginner is Arduino Uno. Arduino uno has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. Arduino accept input from different type sensor (light, sound, pressure, humidity, temperature, vibration). Plug the sensor into input pin the arduino will process and measure input from different signals in addition using simple computer code that you type on arduino software and upload to the board. The board will process the signal and send to output pins the result can be buzzer, led, motor,servo, actuator.

2.) What is electricity? Current? Voltage? Resistance?

Electricity is a form of energy.Two forms of electricity current and static. current electricity power our homes. Electricity is a secondary energy source. We have to convert from another into electric power. Sources of electricity include burning natural gas and coal, nuclear power, natural source of power such as wind water and solar energy.

Voltage is the state of the object how much current to pull. For example the state of battery when charge from a source the flow is positive to negative.

Resistor design to detect flow of electricity.It is measured in Greek Omega character (OHMS). A component resist the flow of electrical energy.It convert some electrical energy into heat. For example if you design circuit with led next to a resistor, the resistor will use up some of the electrical energy and led will receive less energy. resistor give the led the amount of energy it is need and keep the led from receiving to much voltage.

3.) What is a circuit? How does electricity flow in a circuit?

A circuit is like a patch panel. It was to allow electricity to flow to components. Arduino has breadboard circuit that allow electronicity to flow to arduino uno in a specific design structure to produce and input and output result of something like a noise. Electricity would flow from high voltage 5V to low Volts GND. For example the input to activate led light connected pin 6 is sent through jumper wire on breadboard to 5v on the arduino uno and then travel back through jumper wire to led and then back through jumper wire to ground.

4) What is Ohm’s law? When might you use it? How would you use it?

George Simon Ohms discovered the relationship between current, voltage and resistors. Current * resistor determine voltage in circuit. The ohms law explain when the value of 1 element change like resistor then voltage and current also change.

5.) What is a series circuit? Parallel circuit?

Series circuit two switch on breadboard (circuit) in the series. This series mean the same electrical current flow through both of them and they switch both have to be pressed for led light to turn on.

Parallel circuit two switches are in parallel. The electrical current is split between them. if either switch pressed, the led will turn on.

6.) What is the difference between digital and analog signal/voltage? Describe an example.

digital signal is input pin that signal the power pins of the arduino uno or any other microcontroller it range from 0 voltage to 5 voltage. if you design your design your circuit to pull from 5V of the arduino that how much voltage it will to turn on an led for example.

Analog in pin has it own resistors. It is used in code in the loop to read the input pin from the digital pin and store the value to the correct variable that is on the circuit to activate a sensor. sample example

const int redLEDpin=9;

const int redSensorpin= A0;

//red sensor value is sent from pin 9 to Analog 0

int redValue=0;

7.) What is code?

A program is an instruction used to activate an a operation system, or a device to make cause and effect interface like code arduino when switch (cause) is press turn on led light (effect)

8.) What is a variable? How is it used in Arduino?

A variable is a place to store a piece of data. It has a name, a value, and a type. It is used in arduino to delcare input.

int pin = 10       //create variable to name a pin

9.) What is a function? How is it used in Arduino?

function is name to perform a task.

10.) What two functions are required in Arduino code? What do they do?

The two function are void setup and void loop. void setup is main section where you can set up digital pin input and output and void loop control the direction of the instruction of code to arduino board.

11.) Write one function that sets the pins on an Arduino. pinMode();

12.) How do you end a statement in Arduino? semicolon

13.) What are curly braces/brackets used for in Arduino?  first brackets used to say the instruction is going to be begin and the instruction is ending with another bracket.

void setup(){  //begin

}        //end instruction for void setup

14.) Describe one digital function and one analog function.

digitalRead()     //check voltage level on digital input

analogWrite()  // read digital input and store variable to appropriate varible

15.) What are conditional statements in Arduino? Name one and describe its use.

for loop conditional statement. It can be coded to blink 6 led lights on arduino back and forth using a switch button and for certain time using delay function. for loop would set instruction when switch is press each led turn on certain length time using delay function.

16.) What is pulse width modulation (PWM)? How does it work? When might you use it in Arduino? pulse width modulation pwm is used to fade led. pwd coded in arduino software to turn output pin high and low over fix period of time.

17.) What is a multimeter? How do you use one?

an instrument designed to measure electric current, voltage, and usually resistance, typically over several ranges of value. If you testing battery on your device it will tell you if it active with noise or dead.

18.) How do you get code from your Arduino Sketch to an Arduino? What four things should you check for/do?

1. build your circuit and make sure wires are in good

2.plug in usb component

3. type code to arduino software and check for error

4. on arduino software go to tools- board- arduino uno. tools-serial port-click your device

19.) What is the serial monitor for? How do you invoke it in your code? On the Arduino IDE? it is in loop as serial.print(). If your using temperature sensor it will send information from arduino to a computer.

20.) What is baud rate?in electronic bands is unit for symbol rate or modulation rate in symbol per second or pulses per second.

Sensor/Actuator Walk- Part 1

My new assignment or task for a class i am taking is to observe object around me in my community, workplace, at home and various place that i travel to. The objective is to find and compare components in the arduino uno kit and explain sensor and actuators.

What are sensor and actuators? And how they work together

Sensor listen to physical world. It is a cause to make a device have an effect.A sensor is a device that detects events or changes in quantities and provides a corresponding output, generally as an electrical or optical signal. For example: press a button, wave your arms, shout, buttons and knobs

Actuators respond to action of sensor. It the effect of the cause. Actuator convert electronical energy back to physical energy like light, heat and movement.

Microcontroller listen to sensor and talk to actuators.They decide what to do based on a program that you write. For example arduino program responds to if in the program you want led light red when button/switch is press then input is button(sensor) and output is led red(actuators).

Arduino Uno a microcontroller. microcontroller is in keyboard. They control interaction between components. The key are the switch and the key are sent to microcontroller and microcontroller send signal to motherboard which can be seen as actuator make things happen by converting energy into motion or controlling a object. The keyboard has 3 light emitting diodes leds the scroll lock, cap lock and number lock

Inside of my house my smoke detector uses 9 voltage battery. It also has gas sensor, constant flicking light and another output of noise if gas sensor is detection carbon monoxide or carbon dioxide. It also has a noise output like piezo and sensor that alarm when battery is going to die


I was repair a network for an elevator on 42nd street. I notice MTA NYCT elevator use high pressure oil driven hydraulic motors. If i recall actuators charges from source of energy like hydraulic fuild pressure and will convert that into motion to move the elevator up and down for customers. The actuator respond to button press and go into jumper wire maybe and added diodes to ensure current goes one way and when the elevator arrive it make a sound which can be a piezo. the hydraulic fluid can be overheated and stop the elevator from working, that also mean it has a  temperature sensor changes when the system is being used to much.



on the bus when you press stop sign (stop requested) it has liquid crystal display screen

ceiling fan has h bridge control voltage to motor

DC motor used in scooter the Chinese delivery man use

optocoupler used in medical machine

capacitor are used to tune a radio circuit

cell phone like iphone has tilt sensor because some games allow you to use the phone

Temperature sensor




Keyboard Instrument Midterm project

My midterm project was going to be Arduino Uno connected to Nintendo wii nunchuck. The idea was the wii nunchuck would be used to control LED lights, however I spent to much hours trying to figure out how to put it together along with the code and was unsuccessful with the idea. I decided to move on to something else in the arduino project book I felt I could not go wrong with that idea. I choose Keyboard instrument project number 7.

material used for the project

4 switches (push buttons)

4 resistor (10 klohm resistor, 1 megohm resistor and 220 resistor)

piezo (round and black on breadboard)

jumper wire 8


this idea was inspire by someone else blog

The objective:

Lay down card box onto a flat surface. Solder the jumper wire to the resistor and tape it under aluminum foil and when the arduino is plug into personal computer it would play a sound. the sound would depend on how many output you put in the program. The breadboard, piezo and buttons would be eliminated from the project design.

Keyboard Instrument code and explanation included

int buttons [6];                                //set up an array with 6 integers, declare the buttons

int buttons [0] = 2;                        // give the first element of the array the value 2. when button is off (0) = 2

int notes [] = {262,294,330,349};              // list of frequencies you would want for each button

void setup() {                                                  //
void loop(){
int keyVal = analogRead(A0};                      //declare a variable to hold the value read on pin A0.
Serial.println(keyVal);                                    //Each switch has different resistor connected to value                                                                                                connecting it to the power.
if(keyVal == 1023) {                                        //Each value is sent to serial. println and sent to the computer
tone(8, notes[0];                                              //if else statement give it value different tone.
else if (keyVal >= 990 && keyVal <=1010) {
tone (8,notes [1];
else if(keyVal >=505 && keyVal <= 515){
tone (8, notes[2];
else if(keyVal >= 5 && keyVal <= 10){
tone (8, notes [3];
noTone(8);                                                                           //stop playing when there is no button being                                                                                                                  pressed.

Conclusion: program did not work, as a result I was not able to follow through with my objective. I am not sure where the issue coming from.

Toubleshooting steps: I took everything apart and put together the first program in the arduino project book. The program did work when I change sides of the breadboard I was using. Afterward I design the keyboard instrument again and reset the arduino board and I still have nothing.  I had the same program with previous project on my blog.


Arduino Project-Love-O-Meter

I am starting new project called love-o-meter from Arduino project book number 3. There is a component called temperature sensor that will meter how warm  your skin is. The sensor output and use it to red LED turn on and off based on how warm you are. There will be a arduino code to activate response of body temperature.The code will be coded in celsius degrees. The temperature sensor is like a thermometer.

Materials needed

3 LED red    IMG_2186


220 OHM resistor  (3)  IMG_2183

click on the image it will show circle of what type of resistor we are using and how many bands.

jumper wire (8)IMG_2185

temperature sensor (TMP36)   IMG_2181             IMG_2180

Picture show the flat side and rounded side of temperature sensor

Arduino breadboard IMG_2187

Arduino uno

step 1: layer out the material you may onto a white printing paper so that you do not misplace anything. Line up the Arduino uno and breadboard side by side parallel to each other. Wire up breadboard so it connect to ground and power. Red jumper wire (Power connection) will go from 5v (arduino uno) to plus symbol on breadboard. Black jumper wire will go from ground (arduino uno) to negative symbol on arduino can see that the negative color black and positive color red. In addition the breadboard should say at the bottom +- abcde etc..

Step 2: Attach the LEDs. THe cathode (GND connection) (short leg) of each of the leds  go to ground through 220-ohm resistor. Connnect the anodes (power conection) (long leg) of led to pins 2 through 4.

The in between steps: connect jumper wire to breadboard on number 6 and + sign, Connect jumper wire to 7 on boardboard and A0 on arduino uno. Jumper wire to 20 (breadboard) and 4 on uno, 2nd jumper wire on 24 (board) to uno (-3). 3rd jumper wire 28 on (breadboard) to 2(uno). oops there more there would be a shortage if there was no resistors. one 220 ohms resistor connect to b-21 across to a negative,b-25 across,b-28 to negative. negative is ground.

Step 3: place the TMP36 on the breadboard with round part facing away from arduino (PLEASE NOTE: the order if pins is important) connect the left pin of the flat facing side to power. The right pin to ground and connect center pin-pin A) on your arduino board. This is analog input pin 0.

Final step: code the program on arduino free source application and  plug in usb to arduino one and upload the program to the circuit.

conclusion: the love-o-meter project for me did not work. I could not figure out why but it would have been cool if it did.


Love-o-meter code

const int sensorPin = A0;
const float baselineTemp = 20.0;
void setup (){
Serial.begin(9600); //opens the serial port
for (int pinNumber =2; pinNumber <5; pinNumber++){
digitalWrite(pinNumber, LOW);
void loop (){
int sensorVal = analogRead(sensorPin);
Serial.print (“Sensor Value: “);
Serial.print (sensorVal);
//convert the Analog to digital converter ADC
float voltage = (sensorVal/1024.0) * 5.0;
Serial.print (“, Volts: “);
Serial.print (voltage);
Serial.print (“degree C: “);
//convert the voltage to temperature in degrees
float temperature = (voltage – .5) * 100;
if (temperature <baselineTemp){
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}else if (temperature >= baselineTemp+2 && temperature < baselineTemp+4){
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}else if (temperature >= baselineTemp+4 && temperature < baselineTemp+6){
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
delay (1);