Sunday, May 17, 2015

The Magic Wave Symphony

How to build and control an LED bar graph on an Arduino using a hand gesture:
by J.B. Wylzan

Project 13: Electromagnetic Emitter
This project shows how to control the led bar graph by means of the wave of a hand.


Hardware:
LEDs
resistors
switch button
wires
breadboard
computer cable
Arduino UNO

Block Diagram:



Procedure:
1. Use the same prototype as shown above
2. Run the Arduino Interface
3. Select File > New
4. Copy Code #13  below
5. Paste Code #13
6. Click File > Save
7. Click Verify
8. Click Upload
9. Activate the Led Indicators by bringing your hand near the emitter.

Code # 13:  
/* 
    iHackLab Electromagnetic Emitter
    powered by Arduino
    sketched by J.B. Wylzan
    modified by Lawsinium

  This example code is public domain. */
    
//declare variables/constants

int y = 1000;                    // y is a variable with a certain value = 1000
int x = A1                        // x is a variable with uncertain value, 0 or 1

void setup() {
  pinMode(x, INPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
}

void loop() {
 z = analogRead(x);                               // input action: 0 or 1
 if (z == 0)                                               // if  z == 0 
 {
 digitalWrite(8, HIGH);                          // led#8 turns ON
 }
else                                                         // if  z == 1
 {
  digitalWrite(8, LOW);                         // then led#8 turns OFF
      // **project reader starts**           // 
  digitalWrite(4, HIGH);   // turn the LED on 
  delay(500);
  digitalWrite(4, LOW);    // turn the LED off 
  
  digitalWrite(5, HIGH);   // turn the LED on
   delay(500);
  digitalWrite(5, LOW);    // turn the LED off

  digitalWrite(6, HIGH);   // turn the LED on
  delay(500);
  digitalWrite(6, LOW);    // turn the LED off
  
  digitalWrite(7, HIGH);   // turn the LED on
   delay(500); 
  digitalWrite(7, LOW);    // turn the LED off 

  digitalWrite(8, HIGH);   // turn the LED on 
  delay(500);
  digitalWrite(8, LOW);    // turn the LED off
  
  digitalWrite(9, HIGH);   // turn the LED on
  delay(500);
  digitalWrite(9, LOW);    // turn the LED off
  
  digitalWrite(10, HIGH);   // turn the LED on
  delay(500);
  digitalWrite(10, LOW);    // turn the LED off
  
  digitalWrite(11, HIGH);   // turn the LED on 
  delay(500);
  digitalWrite(11, LOW);    // turn the LED off  
  
  digitalWrite(12, HIGH);   // turn the LED on
  delay(500);
  digitalWrite(12, LOW);    // turn the LED off
       
      // **procedure Reader ends** 
  }
}

/*    End of Program       */

Project # 14: Binary Clock



Disclaimer:  We shall not be liable for any loss or damage of whatever nature - direct, indirect, consequential, or otherwise - which may arise as a result of your use of any information on this website. However, if you are interested in using any of the projects for personal or educational purposes, please inform the author by email. 

Public Domain Notice: Copyright (c) 2000. All rights reserved. This article is part of a book entitled iHackRobot. Copies are welcome to be shared or distributed publicly as long proper citations are observed. Please cite as follows: Biotronics: The Silver Species, Joey Lawsin, 1988, USA.

================================================================== 
The Homotronics® and Homodruinos® logos are registered trademarks.
Copyright Biotronics© Inc. iHackRobot®. All Rights Reserved.
Patent Pending. 2000 © ®

L.A.W.S.I.N. Educational Production
 ================================================================== 



No comments:

Post a Comment