HobbyPlay

Arduino Mega and How to Wire Input and Output Devices by Aaron Samuel

This is a small tutorial I put together which provides a walk through of building out electric projects powered by an Arduino (Mega). The intention is to provide an introduction to a beginner on steps involved to get a project going. In this particular example, I demonstrate very briefly the following key items:

 

 

Below you will find the link to the video on Vimeo, and beneath this you will find the code involved in running the final product.

#Peace

Walk Thru

 
//Quick & Dirty Display Code
//Displays, Humidity/Temp/Gas Levels (not converted)

#include <UTFT.h>
#include <dht.h>
#define DHT11_PIN 2
dht DHT;
// Declare which fonts we will be using
extern uint8_t SmallFont[];
//UTFT myGLCD(Model,SDA,SCL,CS,RST,RS)
//QD220A is for QDtech 2.2inch SPI LCD Module,Driver IC:ILI9225
UTFT myGLCD(QD220A,A2,A1,A5,A4,A3);   // Remember to change the model parameter to suit your display module!

void setup()
{
  randomSeed(analogRead(0));
  
// Setup the LCD
  myGLCD.InitLCD();
  myGLCD.InitLCD();//Initializes twice to improve reliability
  myGLCD.setFont(SmallFont);
  myGLCD.clrScr();
}

void loop()
{
  int buf[218];
  int x, x2;
  int y, y2;
  int r;

  // Clear the screen and draw the frame
  myGLCD.clrScr();
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 219, 13);
  myGLCD.setColor(64, 64, 64);
  myGLCD.fillRect(0, 162, 219, 175);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.print("** Dark Photon Weather Station **", CENTER, 1);
  myGLCD.setBackColor(64, 64, 64);
  myGLCD.setColor(255,255,0); 
  myGLCD.print("> www.darkphotonworks.com <", CENTER, 163);




  //print out DHT Humidity readings
  int chk = DHT.read11(DHT11_PIN);
  
  
  switch (chk)
  {
    case DHTLIB_OK:  
    myGLCD.print("** DHT11 Reading OK **", CENTER, 30);
    break;
    case DHTLIB_ERROR_CHECKSUM: 
    myGLCD.print("** DHT11 Reading Checksum Error **", CENTER, 30);
    break;
    case DHTLIB_ERROR_TIMEOUT: 
    myGLCD.print("** DHT11 Timeout Error **", CENTER, 30);
    break;
    default: 
    myGLCD.print("** DHT11 Unknown Error **", CENTER, 30);
    break;
  }
  
  myGLCD.print("Humidity: ",CENTER, 80);

  char buffer [33];
  char *humidity = itoa(DHT.humidity, buffer, 10);
  myGLCD.print(humidity,CENTER, 90);


  myGLCD.setColor(0, 0, 255);
  myGLCD.drawRect(0, 14, 219, 161);
  delay (5000);
  
  
  //clear screen and redraw frame:
  
  myGLCD.clrScr();
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 219, 13);
  myGLCD.setColor(64, 64, 64);
  myGLCD.fillRect(0, 162, 219, 175);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.print("** Dark Photon Weather Station **", CENTER, 1);
  myGLCD.setBackColor(64, 64, 64);
  myGLCD.setColor(255,255,0); 
  myGLCD.print("> www.darkphotonworks.com <", CENTER, 163);
  
  
  switch (chk)
  {
    case DHTLIB_OK:  
    myGLCD.print("** DHT11 Reading OK **", CENTER, 30);
    break;
    case DHTLIB_ERROR_CHECKSUM: 
    myGLCD.print("** DHT11 Reading Checksum Error **", CENTER, 30);
    break;
    case DHTLIB_ERROR_TIMEOUT: 
    myGLCD.print("** DHT11 Timeout Error **", CENTER, 30);
    break;
    default: 
    myGLCD.print("** DHT11 Unknown Error **", CENTER, 30);
    break;
  }
  
  // print out temp readings 
  myGLCD.print("Temperature: ",CENTER, 80);

  char buffer1 [33];
  char *temp = itoa(DHT.temperature, buffer1, 10);
  myGLCD.print(temp,CENTER, 90);


  myGLCD.setColor(0, 0, 255);
  myGLCD.drawRect(0, 14, 219, 161);
  delay (5000);
  
  
  //clear screen and redraw frame:
  
  myGLCD.clrScr();
  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 219, 13);
  myGLCD.setColor(64, 64, 64);
  myGLCD.fillRect(0, 162, 219, 175);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.print("** Dark Photon Weather Station **", CENTER, 1);
  myGLCD.setBackColor(64, 64, 64);
  myGLCD.setColor(255,255,0); 
  myGLCD.print("> www.darkphotonworks.com <", CENTER, 163);
  // print out gas levels
  myGLCD.print("Gas Level: ",CENTER, 80);
  
  int iSensorValue = analogRead(A8);
  char gasBuffer [33];
  char *myGas = itoa(iSensorValue, gasBuffer, 10);
  
  myGLCD.print(myGas,CENTER, 90);
  delay (5000);
  
}



Lab Play: Saturday 1/24/15 by Aaron Samuel

Converting an RC car to an autonomously controlled drone. Basic gutting of the existing body and logic board (lost remote control), added an Arduino Uno with a Motor Shield to power 2 motors (rear wheel drive & left-right). Replaced the connections, additionally adding an ultrasonic sensor which provides echolocation capabilities. At this point both the sensors and motors are working well, I am working on wrapping up the final code which pulls both functionalities together to provide for autonomous movement.

Testing echolocation func

Lab Play: 1/24/15 (Time Lapse Camera with 180 degree turret) by Aaron Samuel

Started up a small project this weekend. I am utilizing a Raspberry Pi B+ model micro controller loaded with Raspbian with a Pi camera attached to the board for image capture. Using an external power source (6 volt battery pack) to provide positive and ground to bread board rails, I was able to attach the signal pin of a Radio Shack 4.6V - 6V standard servo to GPIO pin 4. Utilizing the software PWM (Phase Width Modulation) module and some time conversions for Milliseconds to Microseconds moving the servo a 0, 30, 60, 90, 120, 150 degrees are all possible by sending the proper length signals. Picture log below.

 

TO DO:

  • Create API based service which allows for turret and camera control. The service should also manage disk space either preventing disk full conditions with some sort of notification - or moving files to the cloud or external storage.
  • Utilize ffmpeg & image magick to provide commonly used filters for video/audio
  • Add a microphone.
  • Add status lights to indicate recording in progress or possible issues such as disk space.

Calibrating the turret for proper camera contr

The beta version demo. Software side is not yet complete, this is a simple demonstration of

Lab Play: Sunday 1/11/15 by Aaron Samuel

I'm planning out a DIY project (Bird Shelter) to get a more intimate analysis on the life of Bedford Stuyvesant birds. I envision utilizing a series of relay modules along with some IR motion sensors to detect movement (of birds of course) and activate lights & cameras. There may possibly be a servo powered auto-feeder if time allows. This would also be a great project for solar cells to power. I'll be gathering materials over the next few days and writing up a schematic - We will keep y'all posted!

Comic Con: 2014 by Aaron Samuel

This past years comic con festival.