From the Archives: Birth of a blog – 2010/10/22

A blast from the past, on Oct 22, 2010, I wrote in a previous blog:

Well, I started this to help keep track of my project progress. Maybe someday it will lead to something more.

I am currently building an arduino (RBBB) powered remote/monitor for a mobile platform. Here’s what I got after playing around with the hardware that I currently have (waiting for the transceivers and enclosures to be shipped).

 

 

/*
This sketch is written for a RBBB based remote monitor/controller for a mobile sensor platform.
Data monitoring is done by a 20×4 LCD display. (ModernDevice)
Controls are inputed through an accelerometer and buttons (to be added at a later date). (ModernDevice)
Wireless data transmission is done through a HopeRF HM-TR TTL transceiver. (Futurlec)
*/
/*
Special thanks to the following sources of reference:
General – http://tronixstuff.wordpress.com/tutorials/
LCD – http://www.ladyada.net/learn/lcd/charlcd.html
HopeRF – http://www.open.com.au/mikem/arduino/HopeRF/
*/
// include the library code:
#include
// pin setups for RBBB
const int ACCxpin = A5; // accelerometer
const int ACCypin = A4;
const int ACCzpin = A3;
const int TRconfigpin = 2; // tranceiver
const int TRenablepin = 3;
const int LCDRSpin = 5; // lcd
const int LCDENpin = 7;
const int LCD11pin = 9;
const int LCD12pin = 10;
const int LCD13pin = 11;
const int LCD14pin = 12;
// variable values
int xval = 0;
int yval = 0;
int zval = 0;
long lastAccelTestTime = 0;
long lastAccelDisplayTime = 0;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(LCDRSpin, LCDENpin, LCD11pin, LCD12pin, LCD13pin, LCD14pin);
// arduino setup – runs once when powered
void setup() {
// activate transciever – enable HIGH, config LOW
pinMode(TRconfigpin, OUTPUT);
pinMode(TRenablepin, OUTPUT);
digitalWrite(TRconfigpin, LOW);
digitalWrite(TRenablepin, HIGH);
// set up the LCD’s number of columns and rows:
lcd.begin(20, 4);
// print a message to the LCD.
lcd.print(“Accelerometer Test”);
}
// arduino loop – runs continueously when powered
void loop() {
// universal time counter for all loop functions
long thisTime = millis();
// read values from accelerometer every 100ms
if (thisTime > lastAccelTestTime + 100) {
xval = xval + analogRead(ACCxpin);
yval = yval + analogRead(ACCypin);
zval = zval + analogRead(ACCzpin);
lastAccelTestTime = thisTime;
}
// display averaged accelerometer data every 500ms
if (thisTime > lastAccelDisplayTime + 500) {
xval = xval/5;
yval = yval/5;
zval = zval/5;
// set the cursor to column 0, line 1 (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
lcd.print(“X = “);
lcd.print(xval);
lcd.setCursor(0, 2);
lcd.print(“Y = “);
lcd.print(yval);
lcd.setCursor(0, 3);
lcd.print(“Z = “);
lcd.print(zval);
// reset xyz values
xval = 0;
yval = 0;
zval = 0;
lastAccelDisplayTime = thisTime;
}
}

Next Post

Previous Post

Leave a Reply

© 2017 WatchMeMake