Tuesday, June 12, 2012

Week 1 Day 1

Monday:


We started the day by meeting our new team mates, mentors and the support staff that UNT has provided to help make sure we are successful in our assignments. We were also given a tour of the facilities we have access to. My team (Team 1. Yeah, they already know.) has been assigned to a project that will allow us to remotely monitor several environmental factors in an artificial stream complex that UNT operates. Some of the factors we will be looking at include temperature, pH, alkalinity and dissolved oxygen. We will be using the Arduino microprocessor as the controller for the sensor suite we will eventually build and an XBee shield for wireless communication. With that in mind Dr. Fu gave us a brief introduction to the way an Arduino functions. We spent the remainder of our time tinkering with the arduino programming platform starting with the blink application. By the time we were done I had managed to create a morse code sketch that allowed my Arduino UNO to blink out “Hello world”!







Hello world Sketch:




/*
  HELLO WORLD Morse Code
  spells out hello world in morse code using the LED
 */


int led = 13;
// the setup routine runs once when you press reset:
void setup() {              
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);  
void loop() {
  H();                    
  delay(500);              
// wait for half a second
  E();                    
  delay(500);            
  L();                    
  delay(500);              
  L();
  delay(500);            
  O();
  space();
  W();
  delay(500);            
  O();
  delay(500);            
  R();
  delay(500);              
  L();
  delay(500);              
  D();
  space();
}
void S() {
  dot();
  dot();
  dot();
}
void O() {
  dash();
  dash();
  dash();
}
void H() {
  dot();
  dot();
  dot();
  dot();
}
void E() {
  dot();
}
void L() {
  dot();
  dash();
  dot();
  dot();
}
void W() {
  dot();
  dash();
  dash();
}
void R() {
  dot();
  dash();
  dot();
}
void D() {
  dash();
  dot();
  dot();
}
void space() {
  digitalWrite(led, LOW);
  delay(2000);  //delay two seconds
}
void dot() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(250);               // wait for 1/4 second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(125);               // wait for 1/8 second
}
void dash() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);               // wait for half a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(250);               // wait for 1/4 second
}

4 comments:

  1. This might be something useful for you for field programming:

    http://www.basic4ppc.com/forum/basic4android-getting-started-tutorials/18563-how-connect-your-arduino-using-b4a.html

    ReplyDelete
    Replies
    1. Thanks for the heads up! I will look in to that.

      Delete
  2. and I think delay(125) is an eighth second...just for your documentation ;)

    ReplyDelete
    Replies
    1. lol. Thanks for keeping me honest. Any time you see an error please let me know. In the early stages this is mostly going to be after the fact kind of posting but I suspect that as things progress there will end up being some live code going up and the more eyes on the problem the more likely we are to catch mistakes.

      Delete