├── Libraries ├── L3G4200D_README.txt ├── HMC5883L_README.txt ├── L3G4200D │ ├── examples │ │ └── Serial │ │ │ └── Serial.pde │ ├── L3G4200D.h │ └── L3G4200D.cpp ├── HMC5883L │ ├── keywords.txt │ ├── HMC5883L.h │ ├── HMC5883L.cpp │ └── HMC5883L_Example │ │ └── HMC5883L_Example.ino ├── README.md ├── HMC5883L_LICENSE.txt └── L3G4200D_LICENSE.txt ├── assets ├── logo.png └── logo.psd ├── Projects ├── Compass │ ├── Fritzing │ │ ├── Compass.fzz │ │ ├── breadboard.png │ │ ├── schematic.png │ │ └── bom.html │ ├── README.md │ └── Compass │ │ └── Compass.ino ├── Gyroscope │ ├── Fritzing │ │ ├── Gyroscope.fzz │ │ ├── breadboard.png │ │ ├── schematic.png │ │ └── bom.html │ ├── README.md │ └── Gyroscope │ │ └── Gyroscope.ino ├── PIR_Sensor │ ├── Fritzing │ │ ├── schematic.png │ │ ├── PIR_Sensor.fzz │ │ ├── breadboard.png │ │ └── bom.html │ ├── README.md │ └── PIR_Sensor │ │ └── PIR_Sensor.ino ├── RFID_Shield │ ├── Fritzing │ │ ├── RFID_Shield.fzz │ │ ├── breadboard.png │ │ ├── schematic.png │ │ └── bom.html │ ├── README.md │ └── RFID_Shield │ │ └── RFID_Shield.ino ├── NeuroSky_BrainWave_Mobile │ ├── Fritzing │ │ ├── pcb.png │ │ ├── BrainWave.fzz │ │ ├── schematic.png │ │ ├── breadboard.png │ │ └── bom.html │ ├── BrainWaveMobile │ │ └── BrainWaveMobile.ino │ └── Setup │ │ └── Setup.ino ├── README.md ├── Altimeter │ └── Altimeter │ │ └── Altimeter.ino ├── Ultrasound_Sensor │ ├── README.md │ └── Ultrasound_Sensor │ │ └── Ultrasound_Sensor.ino └── BoebotPing │ └── BoebotPing.ino ├── Fritzing ├── Templates │ └── ArduinoUno_HalfBreadboard.fzz └── Parts │ ├── Bluetooth Modem - BlueSMiRF Gold.fzpz │ ├── PING_Ultrasonic │ ├── pcb │ │ └── PING_Ultrasonic_pcbc.svg │ ├── breadboard │ │ └── PING_Ultrasonic_breadboard.svg │ └── schematic │ │ └── PING_Ultrasonic_schematic.svg │ └── BlueSmirf_Gold │ ├── pcb │ └── ArduinoBluetoothBlueSmirf_Gold_pcb.svg │ ├── schematic │ └── ArduinoBluetoothBlueSMiRF_Gold_schematic.svg │ └── breadboard │ └── ArduinoBluetoothBlueSmirf_Gold_breadboard.svg ├── .gitignore └── README.md /Libraries/L3G4200D_README.txt: -------------------------------------------------------------------------------- 1 | Library retrieved from https://github.com/pololu/L3G4200D -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/assets/logo.png -------------------------------------------------------------------------------- /assets/logo.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/assets/logo.psd -------------------------------------------------------------------------------- /Libraries/HMC5883L_README.txt: -------------------------------------------------------------------------------- 1 | Library retrieved from http://bildr.org/2012/02/hmc5883l_arduino/ -------------------------------------------------------------------------------- /Projects/Compass/Fritzing/Compass.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/Compass/Fritzing/Compass.fzz -------------------------------------------------------------------------------- /Projects/Compass/Fritzing/breadboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/Compass/Fritzing/breadboard.png -------------------------------------------------------------------------------- /Projects/Compass/Fritzing/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/Compass/Fritzing/schematic.png -------------------------------------------------------------------------------- /Projects/Gyroscope/Fritzing/Gyroscope.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/Gyroscope/Fritzing/Gyroscope.fzz -------------------------------------------------------------------------------- /Projects/Gyroscope/Fritzing/breadboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/Gyroscope/Fritzing/breadboard.png -------------------------------------------------------------------------------- /Projects/Gyroscope/Fritzing/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/Gyroscope/Fritzing/schematic.png -------------------------------------------------------------------------------- /Projects/PIR_Sensor/Fritzing/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/PIR_Sensor/Fritzing/schematic.png -------------------------------------------------------------------------------- /Projects/PIR_Sensor/Fritzing/PIR_Sensor.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/PIR_Sensor/Fritzing/PIR_Sensor.fzz -------------------------------------------------------------------------------- /Projects/PIR_Sensor/Fritzing/breadboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/PIR_Sensor/Fritzing/breadboard.png -------------------------------------------------------------------------------- /Projects/RFID_Shield/Fritzing/RFID_Shield.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/RFID_Shield/Fritzing/RFID_Shield.fzz -------------------------------------------------------------------------------- /Projects/RFID_Shield/Fritzing/breadboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/RFID_Shield/Fritzing/breadboard.png -------------------------------------------------------------------------------- /Projects/RFID_Shield/Fritzing/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/RFID_Shield/Fritzing/schematic.png -------------------------------------------------------------------------------- /Fritzing/Templates/ArduinoUno_HalfBreadboard.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Fritzing/Templates/ArduinoUno_HalfBreadboard.fzz -------------------------------------------------------------------------------- /Fritzing/Parts/Bluetooth Modem - BlueSMiRF Gold.fzpz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Fritzing/Parts/Bluetooth Modem - BlueSMiRF Gold.fzpz -------------------------------------------------------------------------------- /Projects/NeuroSky_BrainWave_Mobile/Fritzing/pcb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/NeuroSky_BrainWave_Mobile/Fritzing/pcb.png -------------------------------------------------------------------------------- /Projects/NeuroSky_BrainWave_Mobile/Fritzing/BrainWave.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/NeuroSky_BrainWave_Mobile/Fritzing/BrainWave.fzz -------------------------------------------------------------------------------- /Projects/NeuroSky_BrainWave_Mobile/Fritzing/schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/NeuroSky_BrainWave_Mobile/Fritzing/schematic.png -------------------------------------------------------------------------------- /Projects/NeuroSky_BrainWave_Mobile/Fritzing/breadboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manifestinteractive/arduino/HEAD/Projects/NeuroSky_BrainWave_Mobile/Fritzing/breadboard.png -------------------------------------------------------------------------------- /Projects/RFID_Shield/README.md: -------------------------------------------------------------------------------- 1 | ![Arduino & Fritzing Sketches](https://raw.github.com/manifestinteractive/arduino/master/assets/logo.png "Arduino & Fritzing Sketches") 2 | RFID READER 3 | ------- 4 | RFID Reader ID-12 for Arduino 5 | 6 | The circuit: 7 | 8 | * Disconnect the rx serial wire to the ID-12 when uploading the sketch 9 | 10 | Created 2012-07-01 -------------------------------------------------------------------------------- /Projects/README.md: -------------------------------------------------------------------------------- 1 | ![Arduino & Fritzing Sketches](https://raw.github.com/manifestinteractive/arduino/master/assets/logo.png "Arduino & Fritzing Sketches") 2 | Projects Folder 3 | ------- 4 | Each Arduino project also has it's own *Fritzing* folder that contains a .fzz file. I have already rendered out the breadboard & schematic images. You an also find an HTML file in the root of each project containing the Bill of Materials which lists the items you will need for that project. -------------------------------------------------------------------------------- /Libraries/L3G4200D/examples/Serial/Serial.pde: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | L3G4200D gyro; 5 | 6 | void setup() { 7 | Serial.begin(9600); 8 | Wire.begin(); 9 | gyro.enableDefault(); 10 | } 11 | 12 | void loop() { 13 | gyro.read(); 14 | 15 | Serial.print("G "); 16 | Serial.print("X: "); 17 | Serial.print((int)gyro.g.x); 18 | Serial.print(" Y: "); 19 | Serial.print((int)gyro.g.y); 20 | Serial.print(" Z: "); 21 | Serial.println((int)gyro.g.z); 22 | 23 | delay(100); 24 | } -------------------------------------------------------------------------------- /Projects/Gyroscope/README.md: -------------------------------------------------------------------------------- 1 | ![Arduino & Fritzing Sketches](https://raw.github.com/manifestinteractive/arduino/master/assets/logo.png "Arduino & Fritzing Sketches") 2 | GYROSCOPE L3G4200D 3 | ------- 4 | For the 3-Axis L3G4200D ( Rev A 27911 ) Gyroscope Module 5 | 6 | Helpful Info: http://en.wikipedia.org/wiki/Flight_dynamics 7 | 8 | * Pitch ( 3D X Axis ) 9 | * Roll ( 3D Y Axis ) 10 | * Yaw ( 3D Z Axis ) 11 | 12 | The circuit: 13 | 14 | * L3G4200D GND -> Arduino GND 15 | * L3G4200D VIN -> Arduino 5V 16 | * L3G4200D SCL -> Arduino Analog Pin 5 17 | * L3G4200D SDA -> Arduino Analog Pin 4 18 | 19 | Created 2012-07-03 -------------------------------------------------------------------------------- /Libraries/HMC5883L/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Matrix 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | HMC5883L KEYWORD1 10 | MagnetometerRaw KEYWORD1 11 | MagnetometerScaled KEYWORD1 12 | 13 | ####################################### 14 | # Methods and Functions (KEYWORD2) 15 | ####################################### 16 | 17 | ReadRawAxis KEYWORD2 18 | ReadScaledAxis KEYWORD2 19 | SetMeasurementMode KEYWORD2 20 | SetScale KEYWORD2 21 | 22 | XAxis KEYWORD2 23 | YAxis KEYWORD2 24 | ZAxis KEYWORD2 25 | 26 | ####################################### 27 | # Constants (LITERAL1) 28 | ####################################### 29 | 30 | Measurement_Continuous LITERAL1 31 | Measurement_SingleShot LITERAL1 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ############################################ 2 | ## Generic System Ignores 3 | syntax: glob 4 | 5 | !.gitignore 6 | # build directories and files 7 | #hg syntax 8 | target/**.* 9 | #git syntax 10 | target/ 11 | dist/**.* 12 | **/build/* 13 | build/* 14 | *.pyc 15 | # Maven 16 | release.properties 17 | #Eclipse 18 | .settings/*.** 19 | .classpath 20 | .project 21 | # Netbeans 22 | nb-configuration.xml 23 | nbactions.xml 24 | # Backup files left behind by the Emacs editor. 25 | *~ 26 | # Lock files used by the Emacs editor. 27 | .\#* 28 | # Temporary files used by TestMate 29 | ._* 30 | # XCode user data 31 | **.pbxuser 32 | **.mode?v? 33 | **.perspectivev? 34 | # documentation 35 | **.docset/* 36 | # for those crazies using svn and hg at the same time 37 | *.svn* 38 | # Random OS stuff 39 | .DS_Store 40 | Thumbs.db 41 | # temporary folders 42 | syntax: regexp 43 | .*/te?mp/.* 44 | # Temporary files used by the vim editor. 45 | .*.swp 46 | /nbproject/private/ 47 | /nbproject/ 48 | -------------------------------------------------------------------------------- /Libraries/README.md: -------------------------------------------------------------------------------- 1 | ![Arduino & Fritzing Sketches](https://raw.github.com/manifestinteractive/arduino/master/assets/logo.png "Arduino & Fritzing Sketches") 2 | Installing Libraries 3 | ------- 4 | See http://arduino.cc/en/Guide/Environment#libraries for instructions on installing libraries. 5 | 6 | Also a good posting here if you are still confused: 7 | 8 | http://arduino.cc/blog/2009/08/15/new-library-folder-and-compilation-process-in-arduino-0017/ 9 | 10 | Generally, if you have not already created your libraries folder, you will need to do that. 11 | 12 | You can look for where Arduino thinks your folder should go by opening Arduino and going to Preferences. Then just look for your "Sketchbook location:" path. Go into that folder, and create a "libraries" if there is not already one there. Then, just drop any library you want in there. You may need to restart Arduino to get it to show up. 13 | 14 | Licenses & Credits 15 | ------- 16 | If a project I am using has a LICENSE, or README file, I will prefix it with the Lib name in my Libraries folder. -------------------------------------------------------------------------------- /Projects/Altimeter/Altimeter/Altimeter.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ====================================================================== 3 | 4 | ALTIMETER 5 | 6 | For MS5607 ( Rev A 29124) Altimeter Module 7 | 8 | The circuit: 9 | 10 | * 11 | 12 | Created 2012-07-04 13 | Peter Schmalfeldt me@peterschmalfeldt.com 14 | 15 | https://github.com/manifestinteractive/arduino 16 | 17 | ====================================================================== 18 | 19 | ---------------------------------------------------------------------- 20 | CONFIGURATION VARIABLES ( CHANGE THESE TO MEET YOUR NEEDS ) 21 | ---------------------------------------------------------------------- 22 | */ 23 | 24 | 25 | 26 | /* 27 | ---------------------------------------------------------------------- 28 | !!! YOU DO NOT NEED TO CHANGE ANYTHING BELOW HERE !!! 29 | ---------------------------------------------------------------------- 30 | */ 31 | 32 | 33 | 34 | /* Default Arduino Setup Function */ 35 | void setup() 36 | { 37 | 38 | } 39 | 40 | /* Default Arduino Loop Function */ 41 | void loop() 42 | { 43 | 44 | } -------------------------------------------------------------------------------- /Libraries/HMC5883L_LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 bildr community 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /Projects/Compass/README.md: -------------------------------------------------------------------------------- 1 | ![Arduino & Fritzing Sketches](https://raw.github.com/manifestinteractive/arduino/master/assets/logo.png "Arduino & Fritzing Sketches") 2 | HMC5883L COMPASS 3 | ------- 4 | For the 3-Axis HMC5883L ( Rev A 29133 ) Compass Module 5 | 6 | Detailed Info on Chipset: 7 | 8 | * http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/HMC5883L_3-Axis_Digital_Compass_IC.pdf 9 | 10 | Setup for Declination Angle ( required for accurate readings ): 11 | 12 | * Go to http://www.ngdc.noaa.gov/geomag-web/#declination 13 | * Enter your Zip Code in "Lookup location" in right column and click "Get Location" 14 | * Once your location data is populated, choose CSV file in "Calculate Declination" Result -> Result Format in the left column 15 | * Click "Calculate" and open the downloaded CSV File 16 | * Set your declinationAngle below ( line #56 ) to the "Declination in Decimal Degrees" in Column D ( Note that it might be negative, so make sure to copy that too ) 17 | 18 | The circuit: 19 | 20 | * HMC5883L GND -> Arduino GND 21 | * HMC5883L VIN -> Arduino 5V 22 | * HMC5883L SCL -> Arduino Analog Pin 5 23 | * HMC5883L SDA -> Arduino Analog Pin 4 24 | 25 | Created 2012-07-04 -------------------------------------------------------------------------------- /Libraries/L3G4200D_LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Pololu Corporation. For more information, see 2 | 3 | http://www.pololu.com/ 4 | http://forum.pololu.com/ 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated documentation 8 | files (the "Software"), to deal in the Software without 9 | restriction, including without limitation the rights to use, 10 | copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the 12 | Software is furnished to do so, subject to the following 13 | conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | OTHER DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /Projects/Ultrasound_Sensor/README.md: -------------------------------------------------------------------------------- 1 | ![Arduino & Fritzing Sketches](https://raw.github.com/manifestinteractive/arduino/master/assets/logo.png "Arduino & Fritzing Sketches") 2 | PING))) SENSOR 3 | ------- 4 | This sketch reads a PING))) ultrasonic rangefinder and returns the distance to the closest object in range. To do this, it sends a pulse to the sensor to initiate a reading, then listens for a pulse to return. The length of the returning pulse is proportional to the distance of the object from the sensor. 5 | 6 | See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf 7 | 8 | According to Parallax's datasheet for the PING))), there are 73.746 microseconds per inch (i.e. sound travels at 1130 feet per second). This gives the distance travelled by the ping, outbound and return, so we divide by 2 to get the distance of the obstacle. 9 | 10 | The speed of sound is 340 m/s or 29.034 microseconds per centimeter. The ping travels out and back, so to find the distance of the object we take half of the distance travelled. 11 | 12 | The circuit: 13 | 14 | * +V connection of the PING))) attached to +5V 15 | * GND connection of the PING))) attached to ground 16 | * SIG connection of the PING))) attached to digital pin 7 17 | 18 | Created 2012-07-08 19 | -------------------------------------------------------------------------------- /Projects/PIR_Sensor/README.md: -------------------------------------------------------------------------------- 1 | ![Arduino & Fritzing Sketches](https://raw.github.com/manifestinteractive/arduino/master/assets/logo.png "Arduino & Fritzing Sketches") 2 | PIR SENSOR 3 | ------- 4 | For the Parallax PIR Sensor 5 | 6 | Switches a LED according to the state of the sensors output pin. 7 | Determines the beginning and end of continuous motion sequences. 8 | 9 | The sensor's output pin goes to HIGH if motion is present. 10 | However, even if motion is present it goes to LOW from time to time, 11 | which might give the impression no motion is present. 12 | This program deals with this issue by ignoring LOW-phases shorter than a given time, 13 | assuming continuous motion is present during these phases. 14 | 15 | The Parallax PIR Sensor is an easy to use digital infrared motion sensor module. 16 | http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/555-28027/List/0/SortField/4/ProductID/83/Default.aspx 17 | 18 | PIR Sensor Jumper Pin Settings: 19 | 20 | * H (sometimes labeled as "s") = Retrigger ( Output remains HIGH when sensor is retriggered repeatedly. Output is LOW when idle [not triggered]. ) 21 | * L = Normal ( Output goes HIGH then LOW when triggered. Continuous motion results in repeated HIGH/LOW pulses. Output is LOW when idle ) 22 | 23 | The circuit: 24 | 25 | * PIR Ground => Arduino Ground 26 | * PIR VCC => Arduino 5V 27 | * PIR Out => Arduino Digital Pin ~3 28 | 29 | Created 2012-07-02 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Arduino & Fritzing Sketches](https://raw.github.com/manifestinteractive/arduino/master/assets/logo.png "Arduino & Fritzing Sketches") 2 | Introduction 3 | ------- 4 | This is my playground for making Arduino projects. Once I get them working the way I want, I fire up Fritzing and generate a wiring diagram for the project so I can remember how to do it next time. 5 | 6 | So to play with this stuff too, you will need to make sure you have the following applications installed: 7 | 8 | * Download Arduino: http://arduino.cc/en/Main/Software 9 | 10 | * Download Fritzing: http://fritzing.org/download/ 11 | 12 | Assets Folder 13 | ------- 14 | This just has the logo, not really anything important, but needed a place to put it ;) 15 | 16 | 17 | Fritzing Folder 18 | ------- 19 | This folder contains a folder for custom Parts that are not available in the Fritzing application that I have either created, or downloaded from the internet. 20 | 21 | 22 | Libraries Folder 23 | ------- 24 | This will contain Arduino library code that you will need to have installed for projects that #include any libraries. 25 | 26 | 27 | Projects Folder 28 | ------- 29 | Each Arduino project also has it's own *Fritzing* folder that contains a .fzz file. I have already rendered out the breadboard & schematic images. You an also find an HTML file in the root of each project containing the Bill of Materials which lists the items you will need for that project. 30 | 31 | -------------------------------------------------------------------------------- /Libraries/L3G4200D/L3G4200D.h: -------------------------------------------------------------------------------- 1 | #ifndef L3G4200D_h 2 | #define L3G4200D_h 3 | 4 | #include // for byte data type 5 | 6 | // register addresses 7 | 8 | #define L3G4200D_WHO_AM_I 0x0F 9 | 10 | #define L3G4200D_CTRL_REG1 0x20 11 | #define L3G4200D_CTRL_REG2 0x21 12 | #define L3G4200D_CTRL_REG3 0x22 13 | #define L3G4200D_CTRL_REG4 0x23 14 | #define L3G4200D_CTRL_REG5 0x24 15 | #define L3G4200D_REFERENCE 0x25 16 | #define L3G4200D_OUT_TEMP 0x26 17 | #define L3G4200D_STATUS_REG 0x27 18 | 19 | #define L3G4200D_OUT_X_L 0x28 20 | #define L3G4200D_OUT_X_H 0x29 21 | #define L3G4200D_OUT_Y_L 0x2A 22 | #define L3G4200D_OUT_Y_H 0x2B 23 | #define L3G4200D_OUT_Z_L 0x2C 24 | #define L3G4200D_OUT_Z_H 0x2D 25 | 26 | #define L3G4200D_FIFO_CTRL_REG 0x2E 27 | #define L3G4200D_FIFO_SRC_REG 0x2F 28 | 29 | #define L3G4200D_INT1_CFG 0x30 30 | #define L3G4200D_INT1_SRC 0x31 31 | #define L3G4200D_INT1_THS_XH 0x32 32 | #define L3G4200D_INT1_THS_XL 0x33 33 | #define L3G4200D_INT1_THS_YH 0x34 34 | #define L3G4200D_INT1_THS_YL 0x35 35 | #define L3G4200D_INT1_THS_ZH 0x36 36 | #define L3G4200D_INT1_THS_ZL 0x37 37 | #define L3G4200D_INT1_DURATION 0x38 38 | 39 | class L3G4200D 40 | { 41 | public: 42 | typedef struct vector 43 | { 44 | float x, y, z; 45 | } vector; 46 | 47 | vector g; // gyro angular velocity readings 48 | 49 | void enableDefault(void); 50 | 51 | void writeReg(byte reg, byte value); 52 | byte readReg(byte reg); 53 | 54 | void read(void); 55 | 56 | // vector functions 57 | static void vector_cross(const vector *a, const vector *b, vector *out); 58 | static float vector_dot(const vector *a,const vector *b); 59 | static void vector_normalize(vector *a); 60 | }; 61 | 62 | #endif 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /Fritzing/Parts/PING_Ultrasonic/pcb/PING_Ultrasonic_pcbc.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Libraries/HMC5883L/HMC5883L.h: -------------------------------------------------------------------------------- 1 | /* 2 | HMC5883L.h - Header file for the HMC5883L Triple Axis Magnetometer Arduino Library. 3 | Copyright (C) 2011 Love Electronics (loveelectronics.co.uk) / 2012 bildr.org (Arduino 1.0 compatible) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the version 3 GNU General Public License as 7 | published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | 17 | WARNING: THE HMC5883L IS NOT IDENTICAL TO THE HMC5883! 18 | Datasheet for HMC5883L: 19 | http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/HMC5883L_3-Axis_Digital_Compass_IC.pdf 20 | 21 | */ 22 | 23 | #ifndef HMC5883L_h 24 | #define HMC5883L_h 25 | 26 | #include 27 | #include 28 | 29 | 30 | 31 | #define HMC5883L_Address 0x1E 32 | #define ConfigurationRegisterA 0x00 33 | #define ConfigurationRegisterB 0x01 34 | #define ModeRegister 0x02 35 | #define DataRegisterBegin 0x03 36 | 37 | #define Measurement_Continuous 0x00 38 | #define Measurement_SingleShot 0x01 39 | #define Measurement_Idle 0x03 40 | 41 | #define ErrorCode_1 "Entered scale was not valid, valid gauss values are: 0.88, 1.3, 1.9, 2.5, 4.0, 4.7, 5.6, 8.1" 42 | #define ErrorCode_1_Num 1 43 | 44 | struct MagnetometerScaled 45 | { 46 | float XAxis; 47 | float YAxis; 48 | float ZAxis; 49 | }; 50 | 51 | struct MagnetometerRaw 52 | { 53 | int XAxis; 54 | int YAxis; 55 | int ZAxis; 56 | }; 57 | 58 | class HMC5883L 59 | { 60 | public: 61 | HMC5883L(); 62 | 63 | MagnetometerRaw ReadRawAxis(); 64 | MagnetometerScaled ReadScaledAxis(); 65 | 66 | int SetMeasurementMode(uint8_t mode); 67 | int SetScale(float gauss); 68 | 69 | char* GetErrorText(int errorCode); 70 | 71 | protected: 72 | void Write(int address, int byte); 73 | uint8_t* Read(int address, int length); 74 | 75 | private: 76 | float m_Scale; 77 | }; 78 | #endif -------------------------------------------------------------------------------- /Projects/Compass/Fritzing/bom.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fritzing Bill of Materials 6 | 28 | 29 | 30 | 31 |

Bill of Materials: Compass.fzz

32 |

/Volumes/Portable/Arduino/Projects/Compass/Fritzing/Compass.fzz

33 |

Wednesday, July 4 2012, 01:37:00

34 | 35 |

Assembly List

36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |
LabelPart TypeProperties
3-Axis Compass HMC5883LMystery Part - 5 pinspackage THT; hole size 1.0mm,0.508mm; layout Single Row; true; label HMC5883L; pins 5; pin spacing 100mil
Arduino1Arduinoprocessor ATmega; variant Arduino UNO R3
57 |

Shopping List

58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |
AmountPart TypeProperties
1Mystery Part - 5 pinspackage THT; hole size 1.0mm,0.508mm; layout Single Row; true; label HMC5883L; pins 5; pin spacing 100mil
1Arduinoprocessor ATmega; variant Arduino UNO R3
78 |


Exported with Fritzing 0.7.5- http://fritzing.org

79 | 80 | 81 | -------------------------------------------------------------------------------- /Projects/Gyroscope/Fritzing/bom.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fritzing Bill of Materials 6 | 28 | 29 | 30 | 31 |

Bill of Materials: Gyroscope.fzz

32 |

/Volumes/Portable/Arduino/Projects/Gyroscope/Fritzing/Gyroscope.fzz

33 |

Tuesday, July 3 2012, 22:36:42

34 | 35 |

Assembly List

36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |
LabelPart TypeProperties
Arduino1Arduinoprocessor ATmega; variant Arduino UNO R3
L3G4200DMystery Part - 9 pinspackage THT; hole size 1.0mm,0.508mm; layout Single Row; true; label L3G4200D Rev A; pins 9; pin spacing 100mil
57 |

Shopping List

58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |
AmountPart TypeProperties
1Mystery Part - 9 pinspackage THT; hole size 1.0mm,0.508mm; layout Single Row; true; label L3G4200D Rev A; pins 9; pin spacing 100mil
1Arduinoprocessor ATmega; variant Arduino UNO R3
78 |


Exported with Fritzing 0.7.5- http://fritzing.org

79 | 80 | 81 | -------------------------------------------------------------------------------- /Libraries/L3G4200D/L3G4200D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // Defines //////////////////////////////////////////////////////////////// 6 | 7 | // The Arduino two-wire interface uses a 7-bit number for the address, 8 | // and sets the last bit correctly based on reads and writes 9 | #define GYR_ADDRESS (0xD2 >> 1) 10 | 11 | // Public Methods ////////////////////////////////////////////////////////////// 12 | 13 | // Turns on the L3G4200D's gyro and places it in normal mode. 14 | void L3G4200D::enableDefault(void) 15 | { 16 | // 0x0F = 0b00001111 17 | // Normal power mode, all axes enabled 18 | writeReg(L3G4200D_CTRL_REG1, 0x0F); 19 | } 20 | 21 | // Writes a gyro register 22 | void L3G4200D::writeReg(byte reg, byte value) 23 | { 24 | Wire.beginTransmission(GYR_ADDRESS); 25 | Wire.write(reg); 26 | Wire.write(value); 27 | Wire.endTransmission(); 28 | } 29 | 30 | // Reads a gyro register 31 | byte L3G4200D::readReg(byte reg) 32 | { 33 | byte value; 34 | 35 | Wire.beginTransmission(GYR_ADDRESS); 36 | Wire.write(reg); 37 | Wire.endTransmission(); 38 | Wire.requestFrom(GYR_ADDRESS, 1); 39 | value = Wire.read(); 40 | Wire.endTransmission(); 41 | 42 | return value; 43 | } 44 | 45 | // Reads the 3 gyro channels and stores them in vector g 46 | void L3G4200D::read() 47 | { 48 | Wire.beginTransmission(GYR_ADDRESS); 49 | // assert the MSB of the address to get the gyro 50 | // to do slave-transmit subaddress updating. 51 | Wire.write(L3G4200D_OUT_X_L | (1 << 7)); 52 | Wire.endTransmission(); 53 | Wire.requestFrom(GYR_ADDRESS, 6); 54 | 55 | while (Wire.available() < 6); 56 | 57 | uint8_t xla = Wire.read(); 58 | uint8_t xha = Wire.read(); 59 | uint8_t yla = Wire.read(); 60 | uint8_t yha = Wire.read(); 61 | uint8_t zla = Wire.read(); 62 | uint8_t zha = Wire.read(); 63 | 64 | g.x = xha << 8 | xla; 65 | g.y = yha << 8 | yla; 66 | g.z = zha << 8 | zla; 67 | } 68 | 69 | void L3G4200D::vector_cross(const vector *a,const vector *b, vector *out) 70 | { 71 | out->x = a->y*b->z - a->z*b->y; 72 | out->y = a->z*b->x - a->x*b->z; 73 | out->z = a->x*b->y - a->y*b->x; 74 | } 75 | 76 | float L3G4200D::vector_dot(const vector *a,const vector *b) 77 | { 78 | return a->x*b->x+a->y*b->y+a->z*b->z; 79 | } 80 | 81 | void L3G4200D::vector_normalize(vector *a) 82 | { 83 | float mag = sqrt(vector_dot(a,a)); 84 | a->x /= mag; 85 | a->y /= mag; 86 | a->z /= mag; 87 | } -------------------------------------------------------------------------------- /Projects/Gyroscope/Gyroscope/Gyroscope.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ====================================================================== 3 | 4 | GYROSCOPE L3G4200D 5 | 6 | For the 3-Axis L3G4200D ( Rev A 27911 ) Gyroscope Module 7 | 8 | Helpful Info: http://en.wikipedia.org/wiki/Flight_dynamics 9 | 10 | * Pitch ( 3D X Axis ) 11 | * Roll ( 3D Y Axis ) 12 | * Yaw ( 3D Z Axis ) 13 | 14 | The circuit: 15 | 16 | * L3G4200D GND -> Arduino GND 17 | * L3G4200D VIN -> Arduino 5V 18 | * L3G4200D SCL -> Arduino Analog Pin 5 19 | * L3G4200D SDA -> Arduino Analog Pin 4 20 | 21 | Created 2012-07-03 22 | Peter Schmalfeldt me@peterschmalfeldt.com 23 | 24 | https://github.com/manifestinteractive/arduino 25 | 26 | ====================================================================== 27 | */ 28 | 29 | /* Include Required Libraries */ 30 | #include 31 | #include // https://github.com/pololu/L3G4200D 32 | 33 | /* Define Gyrsocope */ 34 | L3G4200D gyro; 35 | 36 | /* 37 | ---------------------------------------------------------------------- 38 | CONFIGURATION VARIABLES ( CHANGE THESE TO MEET YOUR NEEDS ) 39 | ---------------------------------------------------------------------- 40 | */ 41 | 42 | /* Whether or not to debug output */ 43 | bool debug = true; 44 | 45 | /* Time between Serial reads in milliseconds */ 46 | int read_delay = 250; 47 | 48 | /* Serial Baudrate */ 49 | long unsigned int serial_baudrate = 9600; 50 | 51 | /* 52 | ---------------------------------------------------------------------- 53 | !!! YOU DO NOT NEED TO CHANGE ANYTHING BELOW HERE !!! 54 | ---------------------------------------------------------------------- 55 | */ 56 | 57 | /* Default Arduino Setup Function */ 58 | void setup() 59 | { 60 | Serial.begin(serial_baudrate); 61 | Wire.begin(); 62 | gyro.enableDefault(); 63 | } 64 | 65 | /* Default Arduino Loop Function */ 66 | void loop() 67 | { 68 | // Get Gyro Data 69 | gyro.read(); 70 | 71 | // Use Gyro Data 72 | useGyro((int)gyro.g.x, (int)gyro.g.y, (int)gyro.g.z); 73 | 74 | // Wait before doing another read 75 | delay(read_delay); 76 | } 77 | 78 | /* Use Gyroscopes Data to do something cool */ 79 | void useGyro(int pitch, int roll, int yaw) 80 | { 81 | if(debug) 82 | { 83 | String debug_ouptut; 84 | debug_ouptut += "pitch: "; 85 | debug_ouptut += pitch; 86 | debug_ouptut += ", roll: "; 87 | debug_ouptut += roll; 88 | debug_ouptut += ", yaw: "; 89 | debug_ouptut += yaw; 90 | 91 | Serial.println(debug_ouptut); 92 | } 93 | 94 | // YOUR CODE HERE 95 | } -------------------------------------------------------------------------------- /Projects/PIR_Sensor/Fritzing/bom.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fritzing Bill of Materials 6 | 28 | 29 | 30 | 31 |

Bill of Materials: PIR_Sensor.fzz

32 |

/Volumes/Portable/Arduino/Projects/PIR_Sensor/Fritzing/PIR_Sensor.fzz

33 |

Monday, July 2 2012, 22:19:07

34 | 35 |

Assembly List

36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 |
LabelPart TypeProperties
Arduino1Arduinoprocessor ATmega; variant Arduino UNO R3
LED1Green LED - 5mmpackage 5 mm [THT]; leg yes; color Green (565nm)
Parallax PIR Sensor Rev BMystery Part - 3 pinspackage THT; hole size 1.0mm,0.508mm; layout Single Row; true; label PIR; pins 3; pin spacing 100mil; part # 555-28027
R1100 Ω Resistorpackage THT; tolerance ±5%; bands 4; resistance 100Ω; pin spacing 400 mil
65 |

Shopping List

66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 |
AmountPart TypeProperties
1Green LED - 5mmpackage 5 mm [THT]; leg yes; color Green (565nm)
1Mystery Part - 3 pinspackage THT; hole size 1.0mm,0.508mm; layout Single Row; true; label PIR; pins 3; pin spacing 100mil; part # 555-28027
1100 Ω Resistorpackage THT; tolerance ±5%; bands 4; resistance 100Ω; pin spacing 400 mil
1Arduinoprocessor ATmega; variant Arduino UNO R3
94 |


Exported with Fritzing 0.7.5- http://fritzing.org

95 | 96 | 97 | -------------------------------------------------------------------------------- /Fritzing/Parts/PING_Ultrasonic/breadboard/PING_Ultrasonic_breadboard.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Fritzing/Parts/BlueSmirf_Gold/pcb/ArduinoBluetoothBlueSmirf_Gold_pcb.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fritzing footprint generated by brd2svg 6 | 7 | 8 | 9 | element:JP3 10 | 11 | package:1X06 12 | 13 | 14 | 15 | element:U$1 16 | 17 | package:SFE-NEW-WEBLOGO 18 | 19 | 20 | 21 | element:U1 22 | 23 | package:RN41 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Projects/RFID_Shield/Fritzing/bom.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fritzing Bill of Materials 6 | 28 | 29 | 30 | 31 |

Bill of Materials: RFID_Shield.fzz

32 |

/Volumes/Portable/Arduino/Projects/RFID_Shield/_Fritzing/RFID_Shield.fzz

33 |

Monday, July 2 2012, 01:05:33

34 | 35 |

Assembly List

36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 |
LabelPart TypeProperties
Arduino1Arduinoprocessor ATmega; variant Arduino UNO R3
LED1Red LED - 5mmpackage 5 mm [THT]; leg yes; color Red (633nm)
LED2Green LED - 5mmpackage 5 mm [THT]; leg yes; color Green (565nm)
Part1RFID USB Reader
R1100 Ω Resistorpackage THT; tolerance ±5%; bands 4; resistance 100Ω; pin spacing 400 mil
R2100 Ω Resistorpackage THT; tolerance ±5%; bands 4; resistance 100Ω; pin spacing 400 mil
73 |

Shopping List

74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 |
AmountPart TypeProperties
1RFID USB Reader
1Green LED - 5mmpackage 5 mm [THT]; leg yes; color Green (565nm)
1Red LED - 5mmpackage 5 mm [THT]; leg yes; color Red (633nm)
2100 Ω Resistorpackage THT; tolerance ±5%; bands 4; resistance 100Ω; pin spacing 400 mil
1Arduinoprocessor ATmega; variant Arduino UNO R3
106 |


Exported with Fritzing 0.7.4- http://fritzing.org

107 | 108 | 109 | -------------------------------------------------------------------------------- /Projects/NeuroSky_BrainWave_Mobile/Fritzing/bom.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fritzing Bill of Materials 6 | 28 | 29 | 30 | 31 |

Bill of Materials: BrainWave.fzz

32 |

/Users/manifestinteractive/Downloads/BrainWave.fzz

33 |

Tuesday, June 19 2012, 02:30:57

34 | 35 |

Assembly List

36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 |
LabelPart TypeProperties
Arduino1Arduinoprocessor ATmega; variant Arduino UNO R3
Bluetooth Modem - BlueSMiRF Gold1Bluetooth Modem - BlueSMiRF Goldpart # WRL-10268
LED4RGB LED (com. anode, rbg)package 5 mm [THT]; pin order rbg; polarity common anode; rgb RGB
R1180k Ω Resistorpackage THT; tolerance ±5%; bands 4; resistance 180kΩ; pin spacing 400 mil
R2100k Ω Resistorpackage THT; tolerance ±5%; bands 4; resistance 100kΩ; pin spacing 400 mil
R3100k Ω Resistorpackage THT; tolerance ±5%; bands 4; resistance 100kΩ; pin spacing 400 mil
73 |

Shopping List

74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 |
AmountPart TypeProperties
1RGB LED (com. anode, rbg)package 5 mm [THT]; pin order rbg; polarity common anode; rgb RGB
2100k Ω Resistorpackage THT; tolerance ±5%; bands 4; resistance 100kΩ; pin spacing 400 mil
1180k Ω Resistorpackage THT; tolerance ±5%; bands 4; resistance 180kΩ; pin spacing 400 mil
1Bluetooth Modem - BlueSMiRF Goldpart # WRL-10268
1Arduinoprocessor ATmega; variant Arduino UNO R3
106 |


Exported with Fritzing 0.7.4- http://fritzing.org

107 | 108 | 109 | -------------------------------------------------------------------------------- /Libraries/HMC5883L/HMC5883L.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | HMC5883L.cpp - Class file for the HMC5883L Triple Axis Magnetometer Arduino Library. 3 | Copyright (C) 2011 Love Electronics (loveelectronics.co.uk)/ 2012 bildr.org (Arduino 1.0 compatible) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the version 3 GNU General Public License as 7 | published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | 17 | WARNING: THE HMC5883L IS NOT IDENTICAL TO THE HMC5883! 18 | Datasheet for HMC5883L: 19 | http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/HMC5883L_3-Axis_Digital_Compass_IC.pdf 20 | 21 | */ 22 | 23 | #include 24 | #include "HMC5883L.h" 25 | 26 | HMC5883L::HMC5883L() 27 | { 28 | m_Scale = 1; 29 | } 30 | 31 | MagnetometerRaw HMC5883L::ReadRawAxis() 32 | { 33 | uint8_t* buffer = Read(DataRegisterBegin, 6); 34 | MagnetometerRaw raw = MagnetometerRaw(); 35 | raw.XAxis = (buffer[0] << 8) | buffer[1]; 36 | raw.ZAxis = (buffer[2] << 8) | buffer[3]; 37 | raw.YAxis = (buffer[4] << 8) | buffer[5]; 38 | return raw; 39 | } 40 | 41 | MagnetometerScaled HMC5883L::ReadScaledAxis() 42 | { 43 | MagnetometerRaw raw = ReadRawAxis(); 44 | MagnetometerScaled scaled = MagnetometerScaled(); 45 | scaled.XAxis = raw.XAxis * m_Scale; 46 | scaled.ZAxis = raw.ZAxis * m_Scale; 47 | scaled.YAxis = raw.YAxis * m_Scale; 48 | return scaled; 49 | } 50 | 51 | int HMC5883L::SetScale(float gauss) 52 | { 53 | uint8_t regValue = 0x00; 54 | if(gauss == 0.88) 55 | { 56 | regValue = 0x00; 57 | m_Scale = 0.73; 58 | } 59 | else if(gauss == 1.3) 60 | { 61 | regValue = 0x01; 62 | m_Scale = 0.92; 63 | } 64 | else if(gauss == 1.9) 65 | { 66 | regValue = 0x02; 67 | m_Scale = 1.22; 68 | } 69 | else if(gauss == 2.5) 70 | { 71 | regValue = 0x03; 72 | m_Scale = 1.52; 73 | } 74 | else if(gauss == 4.0) 75 | { 76 | regValue = 0x04; 77 | m_Scale = 2.27; 78 | } 79 | else if(gauss == 4.7) 80 | { 81 | regValue = 0x05; 82 | m_Scale = 2.56; 83 | } 84 | else if(gauss == 5.6) 85 | { 86 | regValue = 0x06; 87 | m_Scale = 3.03; 88 | } 89 | else if(gauss == 8.1) 90 | { 91 | regValue = 0x07; 92 | m_Scale = 4.35; 93 | } 94 | else 95 | return ErrorCode_1_Num; 96 | 97 | // Setting is in the top 3 bits of the register. 98 | regValue = regValue << 5; 99 | Write(ConfigurationRegisterB, regValue); 100 | } 101 | 102 | int HMC5883L::SetMeasurementMode(uint8_t mode) 103 | { 104 | Write(ModeRegister, mode); 105 | } 106 | 107 | void HMC5883L::Write(int address, int data) 108 | { 109 | Wire.beginTransmission(HMC5883L_Address); 110 | Wire.write(address); 111 | Wire.write(data); 112 | Wire.endTransmission(); 113 | } 114 | 115 | uint8_t* HMC5883L::Read(int address, int length) 116 | { 117 | Wire.beginTransmission(HMC5883L_Address); 118 | Wire.write(address); 119 | Wire.endTransmission(); 120 | 121 | Wire.beginTransmission(HMC5883L_Address); 122 | Wire.requestFrom(HMC5883L_Address, length); 123 | 124 | uint8_t buffer[length]; 125 | if(Wire.available() == length) 126 | { 127 | for(uint8_t i = 0; i < length; i++) 128 | { 129 | buffer[i] = Wire.read(); 130 | } 131 | } 132 | Wire.endTransmission(); 133 | 134 | return buffer; 135 | } 136 | 137 | char* HMC5883L::GetErrorText(int errorCode) 138 | { 139 | if(ErrorCode_1_Num == 1) 140 | return ErrorCode_1; 141 | 142 | return "Error not defined."; 143 | } -------------------------------------------------------------------------------- /Projects/Ultrasound_Sensor/Ultrasound_Sensor/Ultrasound_Sensor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ====================================================================== 3 | 4 | PING))) SENSOR 5 | 6 | This sketch reads a PING))) ultrasonic rangefinder and returns the 7 | distance to the closest object in range. To do this, it sends a pulse 8 | to the sensor to initiate a reading, then listens for a pulse 9 | to return. The length of the returning pulse is proportional to 10 | the distance of the object from the sensor. 11 | 12 | See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf 13 | 14 | According to Parallax's datasheet for the PING))), there are 15 | 73.746 microseconds per inch (i.e. sound travels at 1130 feet per 16 | second). This gives the distance travelled by the ping, outbound 17 | and return, so we divide by 2 to get the distance of the obstacle. 18 | 19 | The speed of sound is 340 m/s or 29.034 microseconds per centimeter. 20 | The ping travels out and back, so to find the distance of the 21 | object we take half of the distance travelled. 22 | 23 | The circuit: 24 | 25 | * PING 5V -> Arduino 5V 26 | * PING GND -> Arduino GND 27 | * PING SIG -> Arduino digital Pin 7 28 | 29 | Created 2012-07-08 30 | Peter Schmalfeldt me@peterschmalfeldt.com 31 | 32 | https://github.com/manifestinteractive/arduino 33 | 34 | ====================================================================== 35 | 36 | ---------------------------------------------------------------------- 37 | CONFIGURATION VARIABLES ( CHANGE THESE TO MEET YOUR NEEDS ) 38 | ---------------------------------------------------------------------- 39 | */ 40 | 41 | // Whether or not to enable debugging 42 | bool debug = true; 43 | 44 | /* Serial Baudrate */ 45 | long unsigned int serialBaudrate = 9600; 46 | 47 | /* 48 | ---------------------------------------------------------------------- 49 | !!! YOU DO NOT NEED TO CHANGE ANYTHING BELOW HERE !!! 50 | ---------------------------------------------------------------------- 51 | */ 52 | 53 | // this constant won't change. It's the pin number of the sensor's output: 54 | const int pingPin = 7; 55 | 56 | /* Default Arduino Setup Function */ 57 | void setup() 58 | { 59 | // Initialize the serial port. 60 | Serial.begin(serialBaudrate); 61 | } 62 | 63 | /* Default Arduino Loop Function */ 64 | void loop() 65 | { 66 | // establish variables for duration of the ping, and the distance result in inches and centimeters: 67 | long duration; 68 | double inches, cm; 69 | 70 | // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. 71 | // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: 72 | pinMode(pingPin, OUTPUT); 73 | digitalWrite(pingPin, LOW); 74 | delayMicroseconds(2); 75 | digitalWrite(pingPin, HIGH); 76 | delayMicroseconds(5); 77 | digitalWrite(pingPin, LOW); 78 | 79 | // The same pin is used to read the signal from the PING))): a HIGH 80 | // pulse whose duration is the time (in microseconds) from the sending 81 | // of the ping to the reception of its echo off of an object. 82 | pinMode(pingPin, INPUT); 83 | duration = pulseIn(pingPin, HIGH); 84 | 85 | // convert the time into a distance 86 | inches = microsecondsToInches(duration); 87 | cm = microsecondsToCentimeters(duration); 88 | 89 | if(debug) 90 | { 91 | Serial.print(duration); 92 | Serial.print(" ms, "); 93 | Serial.print(inches); 94 | Serial.print(" in, "); 95 | Serial.print(cm); 96 | Serial.println(" cm"); 97 | } 98 | 99 | delay(100); 100 | } 101 | 102 | /* Convert Microseconds to Inches */ 103 | double microsecondsToInches(long microseconds) 104 | { 105 | return ((microseconds / 73.746) / 2.0); 106 | } 107 | 108 | /* Convert Microseconds to Centimeters */ 109 | double microsecondsToCentimeters(long microseconds) 110 | { 111 | return ((microseconds / 29.034) / 2.0); 112 | } 113 | -------------------------------------------------------------------------------- /Fritzing/Parts/PING_Ultrasonic/schematic/PING_Ultrasonic_schematic.svg: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /Projects/RFID_Shield/RFID_Shield/RFID_Shield.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ====================================================================== 3 | 4 | RFID READER 5 | 6 | RFID Reader ID-12 for Arduino 7 | 8 | The circuit: 9 | 10 | * Disconnect the rx serial wire to the ID-12 when uploading the sketch 11 | 12 | Created 2012-07-01 13 | Peter Schmalfeldt me@peterschmalfeldt.com 14 | 15 | https://github.com/manifestinteractive/arduino 16 | 17 | ====================================================================== 18 | 19 | ---------------------------------------------------------------------- 20 | CONFIGURATION VARIABLES ( CHANGE THESE TO MEET YOUR NEEDS ) 21 | ---------------------------------------------------------------------- 22 | */ 23 | 24 | // Register your RFID tags here 25 | char* myTags[] = { 26 | "4C0020FE8C1E", 27 | "4C0020FA5BCD" 28 | }; 29 | 30 | /* 31 | ---------------------------------------------------------------------- 32 | !!! YOU DO NOT NEED TO CHANGE ANYTHING BELOW HERE !!! 33 | ---------------------------------------------------------------------- 34 | */ 35 | 36 | int PinGoodTag = 7; 37 | int PinBadTag = 9; 38 | bool Debug = true; 39 | 40 | /* Default Arduino Setup Function */ 41 | void setup() 42 | { 43 | // connect to the serial port 44 | Serial.begin(9600); 45 | 46 | pinMode(PinGoodTag, OUTPUT); 47 | pinMode(PinBadTag, OUTPUT); 48 | } 49 | 50 | /* Default Arduino Loop Function */ 51 | void loop() 52 | { 53 | char tagString[13]; 54 | int index = 0; 55 | boolean reading = false; 56 | 57 | while(Serial.available()) 58 | { 59 | // read next available byte 60 | int readByte = Serial.read(); 61 | 62 | // begining of tag 63 | if(readByte == 2) 64 | { 65 | reading = true; 66 | } 67 | // end of tag 68 | if(readByte == 3) 69 | { 70 | reading = false; 71 | } 72 | 73 | if(reading && readByte != 2 && readByte != 10 && readByte != 13) 74 | { 75 | //store the tag 76 | tagString[index] = (char)readByte; 77 | index ++; 78 | } 79 | } 80 | 81 | // Check if it is a match 82 | checkTag(tagString); 83 | 84 | // Clear out memory of tag string 85 | memset(tagString,0,sizeof(tagString)); 86 | 87 | // Give Reader time to Reset 88 | delay(150); 89 | } 90 | 91 | /* Check the read tag against known tags */ 92 | void checkTag(char tag[]) 93 | { 94 | // Setup Custom Variables to Hold RFID Data 95 | String scannedRFID; 96 | String acceptedRFID; 97 | 98 | // Cleanup Scanned RFID 99 | scannedRFID = tag; 100 | scannedRFID = scannedRFID.substring(0, 12); 101 | 102 | // empty, no need to contunue 103 | if(scannedRFID.length() != 12) 104 | { 105 | return; 106 | } 107 | 108 | // get size of tags 109 | int size = sizeof(myTags) / sizeof(myTags[0]); 110 | 111 | // loops through tags for validation 112 | for (int i = 0; i < size; i++) 113 | { 114 | // Cleanup Accepted RFID 115 | acceptedRFID = myTags[i]; 116 | acceptedRFID = acceptedRFID.substring(0, 12); 117 | 118 | // Debug Output 119 | if(Debug) 120 | { 121 | Serial.print(scannedRFID); 122 | if(scannedRFID.equals(acceptedRFID)) 123 | { 124 | Serial.print(" == "); 125 | } 126 | else 127 | { 128 | Serial.print(" != "); 129 | } 130 | Serial.print(acceptedRFID); 131 | Serial.println(); 132 | } 133 | 134 | // Check if we have a match 135 | if(scannedRFID.equals(acceptedRFID)) 136 | { 137 | // Trigger Good Tag 138 | goodTag(scannedRFID); 139 | 140 | return; 141 | } 142 | } 143 | 144 | // Trigger Bad Tag 145 | badTag(scannedRFID); 146 | } 147 | 148 | 149 | /* This was a Good Tag */ 150 | void goodTag(String tag) 151 | { 152 | if(Debug) 153 | { 154 | Serial.println("GOOD TAG: " + tag); 155 | Serial.println(); 156 | } 157 | 158 | digitalWrite(PinGoodTag, HIGH); 159 | delay(1000); 160 | digitalWrite(PinGoodTag, LOW); 161 | } 162 | 163 | /* This was a Bad Tag */ 164 | void badTag(String tag) 165 | { 166 | if(Debug) 167 | { 168 | Serial.println("BAD TAG: " + tag); 169 | Serial.println(); 170 | } 171 | 172 | digitalWrite(PinBadTag, HIGH); 173 | delay(1000); 174 | digitalWrite(PinBadTag, LOW); 175 | } 176 | -------------------------------------------------------------------------------- /Fritzing/Parts/BlueSmirf_Gold/schematic/ArduinoBluetoothBlueSMiRF_Gold_schematic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fritzing schematic generated by brd2svg 6 | 7 | Bluetooth 8 | BlueSMiRF 9 | Gold 10 | 11 | 12 | 13 | 14 | TX_5V 15 | 16 | 17 | 18 | RX_5V 19 | 20 | 21 | 22 | RTS_5V 23 | 24 | CTS_5V 25 | 26 | VCC 27 | 28 | GND 29 | 30 | 31 | 32 | PIO4 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Projects/NeuroSky_BrainWave_Mobile/BrainWaveMobile/BrainWaveMobile.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ====================================================================== 3 | 4 | NEUROSKY BRAINWAVE MOBILE - SETUP 5 | 6 | Arduino BlueSMiRF initial BAUDRATE changer 7 | 8 | The circuit: 9 | 10 | * See Wiring Diagram in Fritzing File 11 | 12 | Created 2012-06-19 13 | Peter Schmalfeldt me@peterschmalfeldt.com 14 | 15 | http://arduino.peterschmalfeldt.com 16 | 17 | ====================================================================== 18 | 19 | ---------------------------------------------------------------------- 20 | CONFIGURATION VARIABLES ( CHANGE THESE TO MEET YOUR NEEDS ) 21 | ---------------------------------------------------------------------- 22 | */ 23 | 24 | #define LED 13 25 | #define BAUDRATE 115200 26 | #define DEBUGOUTPUT 1 27 | #define BLUESMIRFON 7 28 | 29 | // checksum variables 30 | byte generatedChecksum = 0; 31 | byte checksum = 0; 32 | int payloadLength = 0; 33 | byte payloadData[64] = { 34 | 0}; 35 | byte poorQuality = 0; 36 | byte attention = 0; 37 | byte meditation = 0; 38 | 39 | // system variables 40 | long lastReceivedPacket = 0; 41 | boolean bigPacket = false; 42 | 43 | ////////////////////////// 44 | // Microprocessor Setup // 45 | ////////////////////////// 46 | void setup() { 47 | pinMode(LED, OUTPUT); 48 | pinMode(BLUESMIRFON, OUTPUT); 49 | digitalWrite(BLUESMIRFON, HIGH); 50 | Serial.begin(BAUDRATE); // USB 51 | } 52 | 53 | //////////////////////////////// 54 | // Read data from Serial UART // 55 | //////////////////////////////// 56 | byte ReadOneByte() { 57 | int ByteRead; 58 | 59 | while(!Serial.available()); 60 | ByteRead = Serial.read(); 61 | 62 | #if DEBUGOUTPUT 63 | Serial.print((char)ByteRead); // echo the same byte out the USB serial (for debug purposes) 64 | #endif 65 | 66 | return ByteRead; 67 | } 68 | 69 | ///////////// 70 | //MAIN LOOP// 71 | ///////////// 72 | void loop() { 73 | 74 | // Look for sync bytes 75 | if(ReadOneByte() == 170) { 76 | if(ReadOneByte() == 170) { 77 | 78 | payloadLength = ReadOneByte(); 79 | if(payloadLength > 169) //Payload length can not be greater than 169 80 | return; 81 | 82 | generatedChecksum = 0; 83 | for(int i = 0; i < payloadLength; i++) { 84 | payloadData[i] = ReadOneByte(); //Read payload into memory 85 | generatedChecksum += payloadData[i]; 86 | } 87 | 88 | checksum = ReadOneByte(); //Read checksum byte from stream 89 | generatedChecksum = 255 - generatedChecksum; //Take one's compliment of generated checksum 90 | 91 | if(checksum == generatedChecksum) { 92 | 93 | poorQuality = 200; 94 | attention = 0; 95 | meditation = 0; 96 | 97 | for(int i = 0; i < payloadLength; i++) { // Parse the payload 98 | switch (payloadData[i]) { 99 | case 2: 100 | i++; 101 | poorQuality = payloadData[i]; 102 | bigPacket = true; 103 | break; 104 | case 4: 105 | i++; 106 | attention = payloadData[i]; 107 | break; 108 | case 5: 109 | i++; 110 | meditation = payloadData[i]; 111 | break; 112 | case 0x80: 113 | i = i + 3; 114 | break; 115 | case 0x83: 116 | i = i + 25; 117 | break; 118 | default: 119 | break; 120 | } // switch 121 | } // for loop 122 | 123 | #if !DEBUGOUTPUT 124 | 125 | // *** Add your code here *** 126 | 127 | if(bigPacket) { 128 | if(poorQuality == 0) 129 | digitalWrite(LED, HIGH); 130 | else 131 | digitalWrite(LED, LOW); 132 | Serial.print("PoorQuality: "); 133 | Serial.print(poorQuality, DEC); 134 | Serial.print(" Attention: "); 135 | Serial.print(attention, DEC); 136 | Serial.print(" Time since last packet: "); 137 | Serial.print(millis() - lastReceivedPacket, DEC); 138 | lastReceivedPacket = millis(); 139 | Serial.print("\n"); 140 | } 141 | #endif 142 | bigPacket = false; 143 | } 144 | else { 145 | // Checksum Error 146 | } // end if else for checksum 147 | 148 | } // end if read 0xAA byte 149 | } // end if read 0xAA byte 150 | } 151 | -------------------------------------------------------------------------------- /Libraries/HMC5883L/HMC5883L_Example/HMC5883L_Example.ino: -------------------------------------------------------------------------------- 1 | /* 2 | HMC5883L_Example.pde - Example sketch for integration with an HMC5883L triple axis magnetomerwe. 3 | Copyright (C) 2011 Love Electronics (loveelectronics.co.uk) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the version 3 GNU General Public License as 7 | published by the Free Software Foundation. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | 17 | */ 18 | 19 | // Reference the I2C Library 20 | #include 21 | // Reference the HMC5883L Compass Library 22 | #include 23 | 24 | // Store our compass as a variable. 25 | HMC5883L compass; 26 | // Record any errors that may occur in the compass. 27 | int error = 0; 28 | 29 | // Out setup routine, here we will configure the microcontroller and compass. 30 | void setup() 31 | { 32 | // Initialize the serial port. 33 | Serial.begin(9600); 34 | 35 | Serial.println("Starting the I2C interface."); 36 | Wire.begin(); // Start the I2C interface. 37 | 38 | Serial.println("Constructing new HMC5883L"); 39 | compass = HMC5883L(); // Construct a new HMC5883 compass. 40 | 41 | Serial.println("Setting scale to +/- 1.3 Ga"); 42 | error = compass.SetScale(1.3); // Set the scale of the compass. 43 | if(error != 0) // If there is an error, print it out. 44 | Serial.println(compass.GetErrorText(error)); 45 | 46 | Serial.println("Setting measurement mode to continous."); 47 | error = compass.SetMeasurementMode(Measurement_Continuous); // Set the measurement mode to Continuous 48 | if(error != 0) // If there is an error, print it out. 49 | Serial.println(compass.GetErrorText(error)); 50 | } 51 | 52 | // Our main program loop. 53 | void loop() 54 | { 55 | // Retrive the raw values from the compass (not scaled). 56 | MagnetometerRaw raw = compass.ReadRawAxis(); 57 | // Retrived the scaled values from the compass (scaled to the configured scale). 58 | MagnetometerScaled scaled = compass.ReadScaledAxis(); 59 | 60 | // Values are accessed like so: 61 | int MilliGauss_OnThe_XAxis = scaled.XAxis;// (or YAxis, or ZAxis) 62 | 63 | // Calculate heading when the magnetometer is level, then correct for signs of axis. 64 | float heading = atan2(scaled.YAxis, scaled.XAxis); 65 | 66 | // Once you have your heading, you must then add your 'Declination Angle', which is the 'Error' of the magnetic field in your location. 67 | // Find yours here: http://www.magnetic-declination.com/ 68 | // Mine is: 2� 37' W, which is 2.617 Degrees, or (which we need) 0.0456752665 radians, I will use 0.0457 69 | // If you cannot find your Declination, comment out these two lines, your compass will be slightly off. 70 | float declinationAngle = 0.0457; 71 | heading += declinationAngle; 72 | 73 | // Correct for when signs are reversed. 74 | if(heading < 0) 75 | heading += 2*PI; 76 | 77 | // Check for wrap due to addition of declination. 78 | if(heading > 2*PI) 79 | heading -= 2*PI; 80 | 81 | // Convert radians to degrees for readability. 82 | float headingDegrees = heading * 180/M_PI; 83 | 84 | // Output the data via the serial port. 85 | Output(raw, scaled, heading, headingDegrees); 86 | 87 | // Normally we would delay the application by 66ms to allow the loop 88 | // to run at 15Hz (default bandwidth for the HMC5883L). 89 | // However since we have a long serial out (104ms at 9600) we will let 90 | // it run at its natural speed. 91 | // delay(66); 92 | } 93 | 94 | // Output the data down the serial port. 95 | void Output(MagnetometerRaw raw, MagnetometerScaled scaled, float heading, float headingDegrees) 96 | { 97 | Serial.print("Raw:\t"); 98 | Serial.print(raw.XAxis); 99 | Serial.print(" "); 100 | Serial.print(raw.YAxis); 101 | Serial.print(" "); 102 | Serial.print(raw.ZAxis); 103 | Serial.print(" \tScaled:\t"); 104 | 105 | Serial.print(scaled.XAxis); 106 | Serial.print(" "); 107 | Serial.print(scaled.YAxis); 108 | Serial.print(" "); 109 | Serial.print(scaled.ZAxis); 110 | 111 | Serial.print(" \tHeading:\t"); 112 | Serial.print(heading); 113 | Serial.print(" Radians \t"); 114 | Serial.print(headingDegrees); 115 | Serial.println(" Degrees \t"); 116 | } -------------------------------------------------------------------------------- /Projects/PIR_Sensor/PIR_Sensor/PIR_Sensor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ====================================================================== 3 | 4 | PIR SENSOR 5 | 6 | For the Parallax PIR Sensor 7 | 8 | Switches a LED according to the state of the sensors output pin. 9 | Determines the beginning and end of continuous motion sequences. 10 | 11 | The sensor's output pin goes to HIGH if motion is present. 12 | However, even if motion is present it goes to LOW from time to time, 13 | which might give the impression no motion is present. 14 | This program deals with this issue by ignoring LOW-phases shorter than a given time, 15 | assuming continuous motion is present during these phases. 16 | 17 | 18 | The Parallax PIR Sensor is an easy to use digital infrared motion sensor module. 19 | http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/555-28027/List/0/SortField/4/ProductID/83/Default.aspx 20 | 21 | PIR Sensor Jumper Pin Settings: 22 | 23 | * H (sometimes labeled as "s") = Retrigger ( Output remains HIGH when sensor is retriggered repeatedly. Output is LOW when idle [not triggered]. ) 24 | * L = Normal ( Output goes HIGH then LOW when triggered. Continuous motion results in repeated HIGH/LOW pulses. Output is LOW when idle ) 25 | 26 | The circuit: 27 | 28 | * PIR Ground => Arduino Ground 29 | * PIR VCC => Arduino 5V 30 | * PIR Out => Arduino Digital Pin ~3 31 | 32 | Created 2012-07-02 33 | Peter Schmalfeldt me@peterschmalfeldt.com 34 | 35 | https://github.com/manifestinteractive/arduino 36 | 37 | ====================================================================== 38 | 39 | ---------------------------------------------------------------------- 40 | CONFIGURATION VARIABLES ( CHANGE THESE TO MEET YOUR NEEDS ) 41 | ---------------------------------------------------------------------- 42 | */ 43 | 44 | // The time we give the sensor to calibrate ( 10-60 secs according to the datasheet - DO NOT MOVE DURING THIS TIME ) 45 | int calibrationTime = 15; 46 | 47 | // The digital pin connected to the PIR sensor's output 48 | int pirPin = 3; 49 | 50 | // The digital pin connected to the LED 51 | int ledPin = 13; 52 | 53 | // The amount of milliseconds the sensor has to be low before we assume all motion has stopped 54 | long unsigned int pause = 5000; 55 | 56 | // Whether or not to enable debugging 57 | bool debug = true; 58 | 59 | /* 60 | ---------------------------------------------------------------------- 61 | !!! YOU DO NOT NEED TO CHANGE ANYTHING BELOW HERE !!! 62 | ---------------------------------------------------------------------- 63 | */ 64 | 65 | int delayTime = 50; 66 | 67 | // Time motion started 68 | long unsigned int startTime; 69 | 70 | // Time Motion Ended 71 | long unsigned int endTime; 72 | 73 | // Difference between endTime & startTime 74 | long unsigned int totalTime; 75 | 76 | // The time when the sensor outputs a low impulse 77 | long unsigned int lowIn; 78 | 79 | // Whether or not there is currently motion going on 80 | boolean inMotion = false; 81 | 82 | // Whether or not pirPin has been on LOW for pause duration or longer 83 | boolean lockLow = true; 84 | 85 | // Whether to take the LOW time from pirPin ( first instance only ) 86 | boolean takeLowTime; 87 | 88 | /* Default Arduino Setup Function */ 89 | void setup() 90 | { 91 | Serial.begin(9600); 92 | pinMode(pirPin, INPUT); 93 | pinMode(ledPin, OUTPUT); 94 | digitalWrite(pirPin, LOW); 95 | 96 | if(debug) 97 | { 98 | Serial.println(); 99 | Serial.print("Calibrating PIR Sensor "); 100 | } 101 | 102 | // Give the sensor some time to calibrate 103 | for(int i = 0; i < calibrationTime; i++) 104 | { 105 | if(debug) 106 | { 107 | Serial.print("."); 108 | } 109 | 110 | delay(1000); 111 | } 112 | 113 | if(debug) 114 | { 115 | Serial.println(" Done"); 116 | Serial.println(); 117 | Serial.println("!!! SENSOR ACTIVE !!!"); 118 | } 119 | 120 | delay(delayTime); 121 | } 122 | 123 | /* Default Arduino Loop Function */ 124 | void loop() 125 | { 126 | if(digitalRead(pirPin) == HIGH) 127 | { 128 | // The led visualizes the sensors output pin state 129 | digitalWrite(ledPin, HIGH); 130 | 131 | // Make sure we wait for a transition to LOW before any further output is made: 132 | if(lockLow) 133 | { 134 | motionStarted(); 135 | } 136 | 137 | takeLowTime = true; 138 | } 139 | 140 | if(digitalRead(pirPin) == LOW) 141 | { 142 | // The led visualizes the sensors output pin state 143 | digitalWrite(ledPin, LOW); 144 | 145 | if(takeLowTime) 146 | { 147 | // Save the time of the transition from high to LOW 148 | lowIn = millis(); 149 | 150 | // Make sure this is only done at the start of a LOW phase 151 | takeLowTime = false; 152 | } 153 | 154 | // If the sensor is low for more than the given pause, we assume that no more motion is going to happen 155 | if( !lockLow && millis() - lowIn > pause) 156 | { 157 | motionEnded(); 158 | } 159 | } 160 | } 161 | 162 | /* Motion Started */ 163 | void motionStarted() 164 | { 165 | lockLow = false; 166 | 167 | inMotion = true; 168 | 169 | startTime = millis()/1000; 170 | endTime = 0; 171 | totalTime = 0; 172 | 173 | if(debug) 174 | { 175 | Serial.println(); 176 | Serial.print("START: Motion Detected at "); 177 | Serial.print(startTime); 178 | Serial.println(" Seconds."); 179 | } 180 | 181 | delay(delayTime); 182 | } 183 | 184 | /* Motion Ended */ 185 | void motionEnded() 186 | { 187 | lockLow = true; 188 | 189 | inMotion = false; 190 | 191 | endTime = (millis() - pause)/1000; 192 | totalTime = (endTime - startTime); 193 | 194 | if(debug) 195 | { 196 | Serial.print("END: Motion Ended at "); 197 | Serial.print(endTime); 198 | Serial.print(" Seconds, Lasting a Total of "); 199 | Serial.print(totalTime); 200 | Serial.println(" Seconds."); 201 | } 202 | 203 | delay(delayTime); 204 | } 205 | 206 | /* Example Function that can be used to check if there currently motion going on */ 207 | bool getInMotion() 208 | { 209 | return inMotion; 210 | } -------------------------------------------------------------------------------- /Projects/Compass/Compass/Compass.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ====================================================================== 3 | 4 | HMC5883L COMPASS 5 | 6 | For the 3-Axis HMC5883L ( Rev A 29133 ) Compass Module 7 | 8 | Detailed Info on Chipset: 9 | 10 | * http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/HMC5883L_3-Axis_Digital_Compass_IC.pdf 11 | 12 | Setup for Declination Angle ( required for accurate readings ): 13 | 14 | * Go to http://www.ngdc.noaa.gov/geomag-web/#declination 15 | * Enter your Zip Code in "Lookup location" in right column and click "Get Location" 16 | * Once your location data is populated, choose CSV file in "Calculate Declination" Result -> Result Format in the left column 17 | * Click "Calculate" and open the downloaded CSV File 18 | * Set your declinationAngle below ( line #56 ) to the "Declination in Decimal Degrees" in Column D ( Note that it might be negative, so make sure to copy that too ) 19 | 20 | The circuit: 21 | 22 | * HMC5883L GND -> Arduino GND 23 | * HMC5883L VIN -> Arduino 5V 24 | * HMC5883L SCL -> Arduino Analog Pin 5 25 | * HMC5883L SDA -> Arduino Analog Pin 4 26 | 27 | Created 2012-07-04 28 | Peter Schmalfeldt me@peterschmalfeldt.com 29 | 30 | https://github.com/manifestinteractive/arduino 31 | 32 | ====================================================================== 33 | 34 | */ 35 | 36 | /* Include Required Libraries */ 37 | #include 38 | #include // http://bildr.org/2012/02/hmc5883l_arduino/ 39 | 40 | /* Define Compass */ 41 | HMC5883L compass; 42 | 43 | /* 44 | ---------------------------------------------------------------------- 45 | CONFIGURATION VARIABLES ( CHANGE THESE TO MEET YOUR NEEDS ) 46 | ---------------------------------------------------------------------- 47 | */ 48 | 49 | /* Whether or not to debug output */ 50 | bool debug = true; 51 | 52 | /* Serial Baudrate */ 53 | long unsigned int serialBaudrate = 9600; 54 | 55 | /* Declination Angle in Decimal Degrees ( See Setup instruction for how to determine this ) */ 56 | float declinationAngle = -1.01244; 57 | 58 | /* Sensor Field Range ( default 1.3 ): Valid values are: 0.88, 1.3, 1.9, 2.5, 4.0, 4.7, 5.6, 8.1 */ 59 | float sensorFieldRange = 1.3; 60 | 61 | 62 | /* 63 | ---------------------------------------------------------------------- 64 | !!! YOU DO NOT NEED TO CHANGE ANYTHING BELOW HERE !!! 65 | ---------------------------------------------------------------------- 66 | */ 67 | 68 | /* Record any errors that may occur in the compass. */ 69 | int error = 0; 70 | 71 | /* Default Arduino Setup Function */ 72 | void setup() 73 | { 74 | // Initialize the serial port. 75 | Serial.begin(serialBaudrate); 76 | 77 | // Start the I2C interface. 78 | if(debug) 79 | { 80 | Serial.println("Starting the I2C interface."); 81 | } 82 | 83 | Wire.begin(); 84 | 85 | // Construct a new HMC5883 compass. 86 | if(debug) 87 | { 88 | Serial.println("Constructing new HMC5883L"); 89 | } 90 | 91 | compass = HMC5883L(); 92 | 93 | // Set the scale of the compass. 94 | if(debug) 95 | { 96 | Serial.print("Setting scale to +/- "); 97 | Serial.print(sensorFieldRange); 98 | Serial.println(" Ga"); 99 | } 100 | 101 | // A bug in HMC5883L lib returns 512 for error, which is not an actual error, so ignoring 102 | error = compass.SetScale(sensorFieldRange); 103 | if(error != 0 && error != 512) 104 | { 105 | if(debug) 106 | { 107 | Serial.print("ERROR: "); 108 | Serial.println(error); 109 | Serial.println(); 110 | Serial.println(compass.GetErrorText(error)); 111 | } 112 | error = 0; 113 | } 114 | 115 | // Set the measurement mode to Continuous 116 | if(debug) 117 | { 118 | Serial.println("Setting measurement mode to continuos."); 119 | } 120 | 121 | error = compass.SetMeasurementMode(Measurement_Continuous); 122 | if(error != 0 && error != 512) 123 | { 124 | if(debug) 125 | { 126 | Serial.print("ERROR: "); 127 | Serial.println(error); 128 | Serial.println(); 129 | Serial.println(compass.GetErrorText(error)); 130 | } 131 | error = 0; 132 | } 133 | } 134 | 135 | /* Default Arduino Loop Function */ 136 | void loop() 137 | { 138 | // Retrive the raw values from the compass (not scaled). 139 | MagnetometerRaw raw = compass.ReadRawAxis(); 140 | 141 | // Retrived the scaled values from the compass (scaled to the configured scale). 142 | MagnetometerScaled scaled = compass.ReadScaledAxis(); 143 | 144 | // Values are accessed like so: 145 | int MilliGauss_OnThe_XAxis = scaled.XAxis;// (or YAxis, or ZAxis) 146 | 147 | // Calculate heading when the magnetometer is level, then correct for signs of axis. 148 | float heading = atan2(scaled.YAxis, scaled.XAxis); 149 | heading += declinationAngle; 150 | 151 | // Correct for when signs are reversed. 152 | if(heading < 0) 153 | { 154 | heading += 2*PI; 155 | } 156 | 157 | // Check for wrap due to addition of declination. 158 | if(heading > 2*PI) 159 | { 160 | heading -= 2*PI; 161 | } 162 | 163 | // Convert radians to degrees for readability. 164 | float headingDegrees = heading * 180/M_PI; 165 | 166 | // Output the data via the serial port. 167 | useCompass(raw, scaled, heading, headingDegrees); 168 | } 169 | 170 | /* Use Compass Data to do something cool */ 171 | void useCompass(MagnetometerRaw raw, MagnetometerScaled scaled, float heading, float headingDegrees) 172 | { 173 | if(debug) 174 | { 175 | Serial.print("Raw:\t"); 176 | Serial.print(raw.XAxis); 177 | Serial.print(" "); 178 | Serial.print(raw.YAxis); 179 | Serial.print(" "); 180 | Serial.print(raw.ZAxis); 181 | Serial.print(" \tScaled:\t"); 182 | 183 | Serial.print(scaled.XAxis); 184 | Serial.print(" "); 185 | Serial.print(scaled.YAxis); 186 | Serial.print(" "); 187 | Serial.print(scaled.ZAxis); 188 | 189 | Serial.print(" \tHeading:\t"); 190 | Serial.print(heading); 191 | Serial.print(" Radians \t"); 192 | Serial.print(headingDegrees); 193 | Serial.print(" Degrees \t"); 194 | 195 | Serial.println(getDirection(headingDegrees)); 196 | } 197 | 198 | // DO SOMETHING COOL HERE 199 | } 200 | 201 | /* What good is all this if we can't set the expected directional info */ 202 | String getDirection(int headingDegrees) 203 | { 204 | if (headingDegrees < 0 || headingDegrees > 360) 205 | { 206 | return false; 207 | } 208 | else if (headingDegrees >= 0 && headingDegrees <= 11.25) 209 | { 210 | return "N"; 211 | } 212 | else if (headingDegrees > 348.75 && headingDegrees <= 360) 213 | { 214 | return "N"; 215 | } 216 | else if (headingDegrees > 11.25 && headingDegrees <= 33.75) 217 | { 218 | return "NNE"; 219 | } 220 | else if (headingDegrees > 33.75 && headingDegrees <= 56.25) 221 | { 222 | return "NE"; 223 | } 224 | else if (headingDegrees > 56.25 && headingDegrees <= 78.75) 225 | { 226 | return "ENE"; 227 | } 228 | else if (headingDegrees > 78.75 && headingDegrees <= 101.25) 229 | { 230 | return "E"; 231 | } 232 | else if (headingDegrees > 101.25 && headingDegrees <= 123.75) 233 | { 234 | return "ESE"; 235 | } 236 | else if (headingDegrees > 123.75 && headingDegrees <= 146.25) 237 | { 238 | return "SE"; 239 | } 240 | else if (headingDegrees > 146.25 && headingDegrees <= 168.75) 241 | { 242 | return "SSE"; 243 | } 244 | else if (headingDegrees > 168.75 && headingDegrees <= 191.25) 245 | { 246 | return "S"; 247 | } 248 | else if (headingDegrees > 191.25 && headingDegrees <= 213.75) 249 | { 250 | return "SSW"; 251 | } 252 | else if (headingDegrees > 213.75 && headingDegrees <= 236.25) 253 | { 254 | return "SW"; 255 | } 256 | else if (headingDegrees > 236.25 && headingDegrees <= 258.75) 257 | { 258 | return "WSW"; 259 | } 260 | else if (headingDegrees > 258.75 && headingDegrees <= 281.25) 261 | { 262 | return "W"; 263 | } 264 | else if (headingDegrees > 281.25 && headingDegrees <= 303.75) 265 | { 266 | return "WNW"; 267 | } 268 | else if (headingDegrees > 303.75 && headingDegrees <= 326.25) 269 | { 270 | return "NW"; 271 | } 272 | else if (headingDegrees > 326.25 && headingDegrees <= 348.75) 273 | { 274 | return "NNW"; 275 | } 276 | } -------------------------------------------------------------------------------- /Projects/NeuroSky_BrainWave_Mobile/Setup/Setup.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ====================================================================== 3 | 4 | NEUROSKY BRAINWAVE MOBILE - SETUP 5 | 6 | Arduino & BlueSMiRF Gold Shield Programming & Factory Reset. 7 | 8 | The circuit: 9 | 10 | * See Wiring Diagram in Fritzing File 11 | 12 | Created 2012-06-19 13 | Peter Schmalfeldt me@peterschmalfeldt.com 14 | 15 | http://arduino.peterschmalfeldt.com 16 | 17 | ====================================================================== 18 | 19 | ---------------------------------------------------------------------- 20 | CONFIGURATION VARIABLES ( CHANGE THESE TO MEET YOUR NEEDS ) 21 | ---------------------------------------------------------------------- 22 | */ 23 | 24 | // Enable Debug Output 25 | const boolean ENABLE_DUBUG_OUTPUT = true; 26 | 27 | // Enable Factory Reset 28 | const boolean ENABLE_FACTORY_RESET = true; 29 | 30 | // Bluetooth MAC Address to your NeuroSky BrainWave Mobile 31 | const char BLUETOOTH_MAC_ADDRESS[13] = "9CB70D75A7DD"; 32 | 33 | // Bluetooth Pass Key for you NeuroSky BrainWave Mobile ( should be "0000" ) 34 | const char BLUETOOTH_PASS_KEY[5] = "0000"; 35 | 36 | /* 37 | ---------------------------------------------------------------------- 38 | !!! YOU DO NOT NEED TO CHANGE ANYTHING BELOW HERE !!! 39 | ---------------------------------------------------------------------- 40 | */ 41 | 42 | // Has the process completed 43 | boolean is_complete = false; 44 | 45 | // Was the process successful 46 | boolean is_successful = false; 47 | 48 | // Check if BlueSMiRF device is in Command Mode 49 | boolean in_command_mode = false; 50 | 51 | // Has the Bluetooth device been Shutdown 52 | boolean shutdown = false; 53 | 54 | // Response from Serial connection 55 | String response; 56 | 57 | // Individual Letter from response 58 | char letter[1]; 59 | 60 | // BlueSMiRF Baudrate 61 | unsigned long BAUDRATE = 115200; 62 | 63 | // Pin that powers BlueSMiRF 64 | const unsigned int PIN_DIGITAL_ON = 7; 65 | 66 | // Red LED, connected to digital pin 11 67 | const unsigned int PIN_LED_RED = 11; 68 | 69 | // Green LED, connected to digital pin 10 70 | const unsigned int PIN_LED_GREEN = 10; 71 | 72 | // Blue LED, connected to digital pin 9 73 | const unsigned int PIN_LED_BLUE = 9; 74 | 75 | // Delay Between Bluetooth Messages 76 | const unsigned int DELAY = 500; 77 | 78 | /* Default Arduino Setup Function */ 79 | void setup() 80 | { 81 | // Initialize pins 82 | pinMode(PIN_DIGITAL_ON, OUTPUT); 83 | pinMode(PIN_LED_RED, OUTPUT); 84 | pinMode(PIN_LED_GREEN, OUTPUT); 85 | pinMode(PIN_LED_BLUE, OUTPUT); 86 | 87 | // Turn BlueSMiRF on 88 | digitalWrite(PIN_DIGITAL_ON, HIGH); 89 | 90 | // Wait for BlueSMiRF to finish turning on 91 | delay(DELAY); 92 | 93 | // Initialize serial ports 94 | if(ENABLE_FACTORY_RESET) 95 | { 96 | BAUDRATE = 57600; 97 | } 98 | 99 | Serial.begin(115200); 100 | 101 | // Enter Programming Mode 102 | enterProgrammingMode(); 103 | } 104 | 105 | /* Default Arduino Loop Function */ 106 | void loop() 107 | { 108 | // Everything loaded and is complete 109 | if(is_successful && is_complete && !in_command_mode && !shutdown) 110 | { 111 | 112 | // Turn BlueSMiRF off, we're done 113 | digitalWrite(PIN_DIGITAL_ON, LOW); 114 | 115 | Serial.flush(); 116 | 117 | logOutput("Completed Successfully :)"); 118 | 119 | Serial.end(); 120 | 121 | // Fade RGB LED to Green 122 | fadeLed(0, 255, 0); 123 | 124 | // Update that we have shutdown bluetooth board 125 | shutdown = true; 126 | } 127 | 128 | // We completed, but not everything was a success 129 | if(is_complete && !is_successful && !shutdown) 130 | { 131 | // Turn BlueSMiRF off, we're done 132 | digitalWrite(PIN_DIGITAL_ON, LOW); 133 | 134 | Serial.flush(); 135 | 136 | logOutput("Completed Unsuccessfully :("); 137 | 138 | Serial.end(); 139 | 140 | delay(5000); 141 | 142 | // Fade RGB LED to Green 143 | fadeLed(255, 0, 0); 144 | 145 | // Update that we have shutdown bluetooth board 146 | shutdown = true; 147 | } 148 | } 149 | 150 | /* Enter Programming Mode */ 151 | void enterProgrammingMode() 152 | { 153 | // Show Activity 154 | blinkLed(255, 255, 255, 5, 50); 155 | 156 | // Send command to put BlueSMiRF into programming mode 157 | if(sendCommand("$$$", "CMD")) 158 | { 159 | in_command_mode = true; 160 | } 161 | else 162 | { 163 | is_complete = true; 164 | logOutput("Failed setting BlueSMiRF into Command Mode"); 165 | return; 166 | } 167 | 168 | // Make sure we are in programming mode before doing anything else 169 | if(in_command_mode) 170 | { 171 | // Reset the BlueSMiRF 172 | if(ENABLE_FACTORY_RESET) 173 | { 174 | factoryReset(); 175 | } 176 | // Setup the BlueSMiRF data 177 | else 178 | { 179 | configureBluetooth(); 180 | } 181 | } 182 | } 183 | 184 | /* Perform Factory Reset */ 185 | void factoryReset() 186 | { 187 | // Show Activity 188 | blinkLed(0, 0, 255, 5, 50); 189 | 190 | // Perform Factory Reset 191 | if( !sendCommand("SF,1", "AOK")) 192 | { 193 | is_complete = true; 194 | logOutput("Failed factory resetting BlueSMiRF"); 195 | return; 196 | } 197 | 198 | delay(DELAY); 199 | 200 | // Set Baudrate to 57600 201 | if( !sendCommand("SU,115", "AOK")) 202 | { 203 | is_complete = true; 204 | logOutput("Failed setting BlueSMiRF Baudrate"); 205 | return; 206 | } 207 | 208 | // Continue on to Configure Bluetooth now that it was reset 209 | configureBluetooth(); 210 | } 211 | 212 | /* Configure BlueSMiRF Bluetooth with your settings */ 213 | void configureBluetooth() 214 | { 215 | // Show Activity 216 | blinkLed(255, 255, 255, 5, 50); 217 | 218 | // Perform Factory Reset 219 | String build_command = "SR,"; 220 | build_command += BLUETOOTH_MAC_ADDRESS; 221 | 222 | if( !sendCommand(build_command, "AOK")) 223 | { 224 | is_complete = true; 225 | logOutput("Failed to set MAC Address"); 226 | return; 227 | } 228 | 229 | //Set the passkey 230 | build_command = "SP,"; 231 | build_command += BLUETOOTH_PASS_KEY; 232 | 233 | if( !sendCommand(build_command, "AOK")) 234 | { 235 | is_complete = true; 236 | logOutput("Failed to set Pass Key"); 237 | return; 238 | } 239 | 240 | // Set the BlueSMiRF mode 241 | if( !sendCommand("SM,3", "AOK")) 242 | { 243 | is_complete = true; 244 | logOutput("Failed to Change Mode"); 245 | return; 246 | } 247 | 248 | // Exit command mode 249 | if( !sendCommand("---", "END")) 250 | { 251 | is_complete = true; 252 | logOutput("Failed to exit BlueSMiRF CMD Mode"); 253 | return; 254 | } 255 | 256 | // Update Setting and Exist Factory Reset 257 | in_command_mode = false; 258 | is_complete = true; 259 | is_successful = true; 260 | } 261 | 262 | /* Handy Function to Send Commands to BlueSMiRF */ 263 | bool sendCommand(String command, String expected_response) 264 | { 265 | // Flush Any Existing Data from Other Calls 266 | Serial.flush(); 267 | 268 | // Send command to BlueSMiRF, but check if its the initial $$$ command since it cannot have a return 269 | if(command == "$$$") 270 | { 271 | Serial.print(command); 272 | } 273 | else 274 | { 275 | Serial.println(command); 276 | } 277 | 278 | // Wait for BlueSMiRF to receive command 279 | delay(DELAY); 280 | 281 | // Fetch Response 282 | response = ""; 283 | while(Serial.available() > 0) 284 | { 285 | letter[0] = (char)Serial.read(); 286 | if(letter[0] != '\r' && letter[0] != '\n') 287 | { 288 | response += letter[0]; 289 | } 290 | } 291 | 292 | // Flush Response 293 | Serial.flush(); 294 | 295 | // Make sure we got the response we wanted 296 | if(response == expected_response) 297 | { 298 | return true; 299 | } 300 | else 301 | { 302 | logOutput("Executing Command: " + command); 303 | logOutput("Expected Response: " + expected_response); 304 | logOutput("Actual Response: " + response); 305 | 306 | return false; 307 | } 308 | } 309 | 310 | /* Fade In/Out RGB Led */ 311 | void fadeLed(int red, int green, int blue) 312 | { 313 | int new_red = 0; 314 | int new_green = 0; 315 | int new_blue = 0; 316 | 317 | // Fade RGB LED to Red 318 | for(int fadeValue = 255; fadeValue >= 0; fadeValue -=5) 319 | { 320 | new_red = (red == 0) ? fadeValue : red; 321 | new_green = (green == 0) ? fadeValue : green; 322 | new_blue = (blue == 0) ? fadeValue : blue; 323 | 324 | analogWrite(PIN_LED_RED, new_red); 325 | analogWrite(PIN_LED_GREEN, new_green); 326 | analogWrite(PIN_LED_BLUE, new_blue); 327 | 328 | delay(10); 329 | } 330 | 331 | delay(2500); 332 | 333 | blinkLed(new_red, new_green, new_blue, 5, 100); 334 | 335 | delay(2500); 336 | 337 | // Fade RGB LED Off 338 | for(int fadeValue = 255; fadeValue >= 0; fadeValue -=5) 339 | { 340 | new_red = (red == 0) ? red : fadeValue; 341 | new_green = (green == 0) ? green : fadeValue; 342 | new_blue = (blue == 0) ? blue : fadeValue; 343 | 344 | analogWrite(PIN_LED_RED, new_red); 345 | analogWrite(PIN_LED_GREEN, new_green); 346 | analogWrite(PIN_LED_BLUE, new_blue); 347 | 348 | delay(10); 349 | } 350 | } 351 | 352 | /* Blink RGB Led */ 353 | void blinkLed(int red, int green, int blue, int count, int speed) 354 | { 355 | for(int i = 0; i < count; i++) 356 | { 357 | if ( (i % 2) == 0) 358 | { 359 | analogWrite(PIN_LED_RED, red); 360 | analogWrite(PIN_LED_GREEN, green); 361 | analogWrite(PIN_LED_BLUE, blue); 362 | } 363 | else 364 | { 365 | analogWrite(PIN_LED_RED, 0); 366 | analogWrite(PIN_LED_GREEN, 0); 367 | analogWrite(PIN_LED_BLUE, 0); 368 | } 369 | 370 | delay(speed); 371 | } 372 | } 373 | 374 | /* Log Output if Debugging is Enabled */ 375 | void logOutput(String message) 376 | { 377 | if(ENABLE_DUBUG_OUTPUT) 378 | { 379 | Serial.println(message); 380 | } 381 | } 382 | -------------------------------------------------------------------------------- /Projects/BoebotPing/BoebotPing.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ====================================================================== 3 | 4 | Beo-Bot with PING))) Sensor 5 | 6 | 7 | 8 | The circuit: 9 | 10 | * 11 | 12 | Created 2012-07-29 13 | Peter Schmalfeldt me@peterschmalfeldt.com 14 | 15 | https://github.com/manifestinteractive/arduino 16 | 17 | License: http://creativecommons.org/licenses/by-sa/3.0/ 18 | 19 | This Arduino Sketch is licensed under a 20 | Creative Commons Attribution-ShareAlike 3.0 License. 21 | 22 | ====================================================================== 23 | */ 24 | 25 | // Include servo library 26 | #include 27 | 28 | // include the SoftwareSerial library so we can use it to talk to the Emic 2 module 29 | #include 30 | 31 | /* 32 | ---------------------------------------------------------------------- 33 | CONFIGURATION VARIABLES ( CHANGE THESE TO MEET YOUR NEEDS ) 34 | ---------------------------------------------------------------------- 35 | */ 36 | 37 | // Whether or not to enable debugging 38 | bool debug = true; 39 | 40 | /* Serial Baudrate */ 41 | long unsigned int serialBaudrate = 57600; 42 | long unsigned int serialBaudrateTextToSpeech = 9600; 43 | 44 | /* Setup some octaves for Tone ( Key of A - octave1[0] = A1, octave1[1] = A1# ) */ 45 | int octave1[] = { 440, 477, 513, 550, 587, 623, 660, 697, 733, 770, 807, 843 }; 46 | int octave2[] = { 880, 917, 953, 990, 1027, 1063, 1100, 1137, 1173, 1210, 1247, 1283 }; 47 | int octave3[] = { 1320, 1357, 1393, 1430, 1467, 1503, 1540, 1577, 1613, 1650, 1687, 1723 }; 48 | int octave4[] = { 1760, 1797, 1833, 1870, 1907, 1943, 1980, 2017, 2053, 2090, 2126, 2163 }; 49 | int octave5[] = { 2200, 2237, 2273, 2310, 2347, 2383, 2420, 2457, 2493, 2530, 2567, 2603 }; 50 | 51 | /* Define Servo Measures */ 52 | int leftSpeed = 1500; 53 | int rightSpeed = 1500; 54 | 55 | /* Head Offset ( cant always mount on 90 ) */ 56 | signed int headOffset = -4; 57 | 58 | // Pin Numbers 59 | //const int pinRx = 8; 60 | //const int pinTx = 9; 61 | const int pinTone = 4; 62 | const int pinServoLeft = 10; 63 | const int pinServoRight = 11; 64 | const int pinServoHead = 12; 65 | const int pinPingSensor = 8; 66 | 67 | // Define Text to Speech Module Serial 68 | //SoftwareSerial textToSpeechSerial(pinRx, pinTx); 69 | 70 | /* 71 | ---------------------------------------------------------------------- 72 | !!! YOU DO NOT NEED TO CHANGE ANYTHING BELOW HERE !!! 73 | ---------------------------------------------------------------------- 74 | */ 75 | 76 | // Declare left, right & head servos 77 | Servo servoLeft; 78 | Servo servoRight; 79 | Servo servoHead; 80 | 81 | // establish variables for duration of the ping, and the distance result in inches and centimeters: 82 | long duration; 83 | double inches, cm; 84 | 85 | /* Default Arduino Setup Function */ 86 | void setup() 87 | { 88 | // Generic Serial to receive other Serial communications 89 | Serial.begin(serialBaudrate); 90 | 91 | if(debug) 92 | { 93 | Serial.println("Starting up Robot"); 94 | } 95 | 96 | // Play Startup Sound 97 | startupTone(); 98 | 99 | // Attach Header Servo & PING))) Sensor 100 | attachHead(); 101 | 102 | // Attach Text to Speech Module 103 | //attachVoice(); 104 | 105 | // Attach Left & Right Servos 106 | attachFeet(); 107 | } 108 | 109 | /* Default Arduino Loop Function */ 110 | void loop() 111 | { 112 | avoidHittingStuff(); 113 | } 114 | 115 | /* 116 | ---------------------------------------------------------------------- 117 | FUNCTIONS RELATED TO HEAD 118 | ---------------------------------------------------------------------- 119 | */ 120 | 121 | /* Attach Text to Speech Module */ 122 | void attachVoice() 123 | { 124 | if(debug) 125 | { 126 | Serial.println("Attaching Voice"); 127 | } 128 | 129 | // set the data rate for the SoftwareSerial port 130 | //textToSpeechSerial.begin(serialBaudrateTextToSpeech); 131 | 132 | //delay(100); 133 | 134 | // Get current settings 135 | //textToSpeechSerial.print('X'); 136 | //textToSpeechSerial.print('\n'); 137 | 138 | // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it 139 | //while (textToSpeechSerial.read() != ':'); 140 | 141 | // Short delay 142 | //delay(10); 143 | 144 | // Flush the receive buffer 145 | //textToSpeechSerial.flush(); 146 | } 147 | 148 | /* Attach Servos */ 149 | void attachHead() 150 | { 151 | if(debug) 152 | { 153 | Serial.println("Attaching Head"); 154 | } 155 | 156 | // Setup Servo Pins 157 | servoHead.attach(pinServoHead); 158 | 159 | // Move Head Servo to Center 160 | look(90); 161 | } 162 | 163 | /* Turn Head to this Angle */ 164 | void look(int angle) 165 | { 166 | // Set angle and adjust for offset 167 | angle = (angle + headOffset); 168 | 169 | // Make sure angle is within limits 170 | angle = constrain(angle, 0, 180); 171 | 172 | // Left wheel counterclockwise 173 | servoHead.write(angle); 174 | } 175 | 176 | /* Read PING))) Sensor */ 177 | double readPingSensor(String unit) 178 | { 179 | // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. 180 | // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: 181 | pinMode(pinPingSensor, OUTPUT); 182 | digitalWrite(pinPingSensor, LOW); 183 | delayMicroseconds(2); 184 | digitalWrite(pinPingSensor, HIGH); 185 | delayMicroseconds(5); 186 | digitalWrite(pinPingSensor, LOW); 187 | 188 | 189 | // The same pin is used to read the signal from the PING))): a HIGH 190 | // pulse whose duration is the time (in microseconds) from the sending 191 | // of the ping to the reception of its echo off of an object. 192 | pinMode(pinPingSensor, INPUT); 193 | duration = pulseIn(pinPingSensor, HIGH); 194 | 195 | // convert the time into a distance 196 | inches = microsecondsToInches(duration); 197 | cm = microsecondsToCentimeters(duration); 198 | 199 | delay(500); 200 | 201 | if(unit == "ms") 202 | { 203 | return duration; 204 | } 205 | else if(unit == "in") 206 | { 207 | return inches; 208 | } 209 | else if(unit == "cm") 210 | { 211 | return cm; 212 | } 213 | } 214 | 215 | /* Say Text */ 216 | void sayText(String text) 217 | { 218 | // Stop any existing text that is playing 219 | //textToSpeechSerial.print('X'); 220 | //textToSpeechSerial.print('\n'); 221 | 222 | // Send the desired string to convert to speech 223 | //textToSpeechSerial.print('S'); 224 | //textToSpeechSerial.print(text); 225 | //textToSpeechSerial.print('\n'); 226 | 227 | // Wait here until the Emic 2 responds with a ":" indicating it's ready to accept the next command 228 | //while (textToSpeechSerial.read() != ':'); 229 | 230 | // Short delay 231 | //delay(10); 232 | 233 | // Flush the receive buffer 234 | //textToSpeechSerial.flush(); 235 | } 236 | 237 | /* 238 | ---------------------------------------------------------------------- 239 | FUNCTIONS RELATED TO FEET 240 | ---------------------------------------------------------------------- 241 | */ 242 | 243 | /* Attach Servos */ 244 | void attachFeet() 245 | { 246 | // Setup Servo Pins 247 | if(servoLeft.attached() == false) 248 | { 249 | servoLeft.attach(pinServoLeft); 250 | 251 | if(debug) 252 | { 253 | Serial.println("Attaching Left Foot"); 254 | } 255 | } 256 | else 257 | { 258 | if(debug) 259 | { 260 | Serial.println("Left Foot Already Attached"); 261 | } 262 | } 263 | 264 | // Setup Servo Pins 265 | if(servoRight.attached() == false) 266 | { 267 | servoRight.attach(pinServoRight); 268 | 269 | if(debug) 270 | { 271 | Serial.println("Attaching Right Foot"); 272 | } 273 | } 274 | else 275 | { 276 | if(debug) 277 | { 278 | Serial.println("Right Foot Already Attached"); 279 | } 280 | } 281 | 282 | } 283 | 284 | /* Detach Servos */ 285 | void detachFeet() 286 | { 287 | // Setup Servo Pins 288 | if(servoLeft.attached()) 289 | { 290 | servoLeft.detach(); 291 | 292 | if(debug) 293 | { 294 | Serial.println("Detaching Left Foot"); 295 | } 296 | } 297 | else 298 | { 299 | if(debug) 300 | { 301 | Serial.println("Left Foot Already Detached"); 302 | } 303 | } 304 | 305 | // Setup Servo Pins 306 | if(servoRight.attached()) 307 | { 308 | servoRight.detach(); 309 | 310 | if(debug) 311 | { 312 | Serial.println("Detaching Right Foot"); 313 | } 314 | } 315 | else 316 | { 317 | if(debug) 318 | { 319 | Serial.println("Right Foot Already Detached"); 320 | } 321 | } 322 | } 323 | 324 | void avoidHittingStuff() 325 | { 326 | int distance = readPingSensor("ms"); 327 | 328 | if(distance < 2000) 329 | { 330 | look(45); 331 | } 332 | } 333 | 334 | void move(int directionAngle, int speedPercent, int duration) 335 | { 336 | // On standard servos a parameter value of 337 | // 1000 is fully counter-clockwise, 338 | // 2000 is fully clockwise, and 339 | // 1500 is in the middle. 340 | 341 | if(servoLeft.attached() && servoRight.attached() && speedPercent == 0) 342 | { 343 | detachFeet(); 344 | } 345 | else if(servoLeft.attached() == false && servoRight.attached() == false) 346 | { 347 | attachFeet(); 348 | } 349 | 350 | float percent = (float)speedPercent / 100.0; 351 | 352 | if(directionAngle == 0 || directionAngle == 360) 353 | { 354 | if(debug) 355 | { 356 | Serial.println("Going Forward"); 357 | } 358 | 359 | leftSpeed = 1500 + ( 500 * percent); 360 | rightSpeed = 1500 - ( 500 * percent); 361 | } 362 | else if(directionAngle == 270) 363 | { 364 | if(debug) 365 | { 366 | Serial.println("Going Left"); 367 | } 368 | 369 | leftSpeed = 1500; 370 | rightSpeed = 1500 - ( 500 * percent); 371 | } 372 | else if(directionAngle == 90) 373 | { 374 | if(debug) 375 | { 376 | Serial.println("Going Right"); 377 | } 378 | 379 | leftSpeed = 1500 + ( 500 * percent); 380 | rightSpeed = 1500; 381 | } 382 | else if(directionAngle == 180) 383 | { 384 | if(debug) 385 | { 386 | Serial.println("Going Straight Backwards"); 387 | } 388 | 389 | leftSpeed = 1500 - ( 500 * percent); 390 | rightSpeed = 1500 + ( 500 * percent); 391 | } 392 | else if((directionAngle >= 0 && directionAngle <= 90) || (directionAngle >= 270 && directionAngle <= 360)) 393 | { 394 | if(debug) 395 | { 396 | Serial.println("Going Straight Forward"); 397 | } 398 | 399 | //leftSpeed = 1500; 400 | //rightSpeed = 1500; 401 | } 402 | else if(directionAngle >= 270 && directionAngle <= 360) 403 | { 404 | if(debug) 405 | { 406 | Serial.println("Going Backwards"); 407 | } 408 | } 409 | 410 | if(debug) 411 | { 412 | Serial.print("directionAngle: "); 413 | Serial.print(directionAngle); 414 | Serial.print(", speedPercent: "); 415 | Serial.print(speedPercent); 416 | Serial.print(", percent: "); 417 | Serial.print(percent); 418 | Serial.print(", leftSpeed: "); 419 | Serial.print(leftSpeed); 420 | Serial.print(", rightSpeed: "); 421 | Serial.print(rightSpeed); 422 | Serial.print(", duration: "); 423 | Serial.println(duration); 424 | Serial.println(); 425 | } 426 | 427 | servoLeft.writeMicroseconds(leftSpeed); 428 | servoRight.writeMicroseconds(rightSpeed); 429 | 430 | delay(duration); 431 | } 432 | 433 | /* 434 | ---------------------------------------------------------------------- 435 | MISC FUNCTIONS 436 | ---------------------------------------------------------------------- 437 | */ 438 | 439 | /* Play Startup Tone */ 440 | void startupTone() 441 | { 442 | if(debug) 443 | { 444 | Serial.println("Playing Startup Tone"); 445 | } 446 | 447 | tone(pinTone, octave1[6], 100); 448 | delay(100); 449 | tone(pinTone, (int)octave2[0], 300); 450 | delay(300); 451 | } 452 | 453 | /* Convert Microseconds to Inches */ 454 | double microsecondsToInches(long microseconds) 455 | { 456 | return ((microseconds / 73.746) / 2.0); 457 | } 458 | 459 | /* Convert Microseconds to Centimeters */ 460 | double microsecondsToCentimeters(long microseconds) 461 | { 462 | return ((microseconds / 29.034) / 2.0); 463 | } 464 | 465 | /* 466 | ---------------------------------------------------------------------- 467 | JUST FOR FUN FUNCTIONS 468 | ---------------------------------------------------------------------- 469 | */ 470 | 471 | void sing() 472 | { 473 | // Stop any existing text that is playing 474 | //textToSpeechSerial.print('X'); 475 | //textToSpeechSerial.print('\n'); 476 | 477 | // Sing a song 478 | //textToSpeechSerial.print("D1\n"); 479 | //while (textToSpeechSerial.read() != ':'); // Wait here until the Emic 2 responds with a ":" indicating it's ready to accept the next command 480 | } 481 | 482 | void pimp() 483 | { 484 | servoLeft.writeMicroseconds(2000); 485 | servoRight.writeMicroseconds(1000); 486 | 487 | delay(3000); 488 | 489 | detachFeet(); 490 | 491 | look(145); 492 | 493 | sayText("Well, hello there. I did not see you come in."); 494 | delay(1000); 495 | 496 | look(135); 497 | 498 | sayText("You sure are pretty. How about a song?"); 499 | 500 | delay(1000); 501 | 502 | sayText("Great! Here goes!"); 503 | 504 | delay(1000); 505 | 506 | look(90); 507 | 508 | sing(); 509 | 510 | delay(1000); 511 | 512 | look(135); 513 | 514 | sayText("Thanks. You are pretty amazing your self."); 515 | 516 | delay(1000); 517 | 518 | look(90); 519 | 520 | attachFeet(); 521 | 522 | servoLeft.writeMicroseconds(2000); 523 | servoRight.writeMicroseconds(1000); 524 | 525 | delay(3000); 526 | 527 | detachFeet(); 528 | } 529 | -------------------------------------------------------------------------------- /Fritzing/Parts/BlueSmirf_Gold/breadboard/ArduinoBluetoothBlueSmirf_Gold_breadboard.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fritzing breadboard generated by brd2svg 6 | 7 | layer 21 8 | 9 | text:Stat 10 | Stat 11 | 12 | 13 | text:Connect 14 | Connect 15 | 16 | 17 | element:C1 18 | 19 | package:EIA3216 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | element:C3 32 | 33 | package:EIA3216 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | element:C4 46 | 47 | package:0402-CAP 48 | 49 | 50 | 51 | 52 | element:D1 53 | 54 | package:LED-0603 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | element:D2 63 | 64 | package:LED-0603 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | element:JP1 73 | 74 | package:FIDUCIAL-1X2 75 | 76 | 77 | 78 | element:JP2 79 | 80 | package:1X01NS 81 | 82 | 83 | 84 | element:JP3 85 | 86 | package:1X06 87 | 88 | 89 | 90 | element:JP4 91 | 92 | package:FIDUCIAL-1X2 93 | 94 | 95 | 96 | element:Q1 97 | 98 | package:SOT23-3 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | element:Q2 107 | 108 | package:SOT23-3 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | element:R1 117 | 118 | package:0402-RES 119 | 120 | 121 | 122 | element:R2 123 | 124 | package:0402-RES 125 | 126 | 127 | 128 | element:R3 129 | 130 | package:0402-RES 131 | 132 | 133 | 134 | element:R4 135 | 136 | package:0402-RES 137 | 138 | 139 | 140 | element:R5 141 | 142 | package:0402-RES 143 | 144 | 145 | 146 | element:R6 147 | 148 | package:0402-RES 149 | 150 | 151 | 152 | element:R7 153 | 154 | package:0402-RES 155 | 156 | 157 | 158 | element:R8 159 | 160 | package:0402-RES 161 | 162 | 163 | 164 | element:R9 165 | 166 | package:0402-RES 167 | 168 | 169 | 170 | element:SJ1 171 | 172 | package:SJ_2S-NO 173 | 174 | 175 | 176 | element:U$1 177 | 178 | package:SFE-NEW-WEBLOGO 179 | 180 | 181 | 182 | element:U1 183 | 184 | package:RN41 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | element:U3 199 | 200 | package:SOT23-5 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | BlueSMiRF Gold 262 | 263 | BlueSMiRF 264 | Gold 265 | 266 | 267 | 268 | 269 | 270 | 271 | --------------------------------------------------------------------------------