Harriet Noons / Mbed 2 deprecated main

Dependencies:   TextLCD mbed

Committer:
hnoons
Date:
Thu May 02 14:23:16 2013 +0000
Revision:
0:b41e9479d15b
Child:
1:49089afba57b
tryout

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hnoons 0:b41e9479d15b 1 #include "mbed.h"
hnoons 0:b41e9479d15b 2 #include "TextLCD.h"
hnoons 0:b41e9479d15b 3
hnoons 0:b41e9479d15b 4 Serial xbee1(p9, p10);
hnoons 0:b41e9479d15b 5 DigitalOut rst1(p11);
hnoons 0:b41e9479d15b 6 Serial sndpn(p14, p13);
hnoons 0:b41e9479d15b 7
hnoons 0:b41e9479d15b 8 DigitalOut myled(LED1);
hnoons 0:b41e9479d15b 9 DigitalOut myled2(LED2);
hnoons 0:b41e9479d15b 10 //DigitalIn flag(p8);
hnoons 0:b41e9479d15b 11
hnoons 0:b41e9479d15b 12 TextLCD lcd(p15, p16, p17, p18, p19, p20);
hnoons 0:b41e9479d15b 13
hnoons 0:b41e9479d15b 14 int main() {
hnoons 0:b41e9479d15b 15 rst1 = 0; //Set reset pin to 0
hnoons 0:b41e9479d15b 16 myled = 0;
hnoons 0:b41e9479d15b 17 myled2= 0;
hnoons 0:b41e9479d15b 18 wait_ms(1);
hnoons 0:b41e9479d15b 19 rst1 = 1; //Set reset pin to 1
hnoons 0:b41e9479d15b 20 wait_ms(1);
hnoons 0:b41e9479d15b 21
hnoons 0:b41e9479d15b 22 lcd.printf("Welcome\n");
hnoons 0:b41e9479d15b 23 wait(2);
hnoons 0:b41e9479d15b 24 lcd.cls();
hnoons 0:b41e9479d15b 25
hnoons 0:b41e9479d15b 26 int id;
hnoons 0:b41e9479d15b 27 int PIN;
hnoons 0:b41e9479d15b 28 int idPIN;
hnoons 0:b41e9479d15b 29 while(1)
hnoons 0:b41e9479d15b 30 {
hnoons 0:b41e9479d15b 31 myled = 1;
hnoons 0:b41e9479d15b 32 if (xbee1.readable())
hnoons 0:b41e9479d15b 33 {
hnoons 0:b41e9479d15b 34 xbee1.scanf(" %d", &id);
hnoons 0:b41e9479d15b 35 myled = 0;
hnoons 0:b41e9479d15b 36 PIN = rand()%9000 + 1000;
hnoons 0:b41e9479d15b 37 // prev = data;
hnoons 0:b41e9479d15b 38 wait(0.01);
hnoons 0:b41e9479d15b 39 lcd.printf(" Pin: %d", PIN);
hnoons 0:b41e9479d15b 40
hnoons 0:b41e9479d15b 41 while(1) {
hnoons 0:b41e9479d15b 42
hnoons 0:b41e9479d15b 43 idPIN = (id*10000)+PIN;
hnoons 0:b41e9479d15b 44 sndpn.printf("%d \r", idPIN);
hnoons 0:b41e9479d15b 45 wait(10);
hnoons 0:b41e9479d15b 46 }
hnoons 0:b41e9479d15b 47 }
hnoons 0:b41e9479d15b 48 lcd.cls();
hnoons 0:b41e9479d15b 49
hnoons 0:b41e9479d15b 50
hnoons 0:b41e9479d15b 51 }
hnoons 0:b41e9479d15b 52 }
hnoons 0:b41e9479d15b 53
hnoons 0:b41e9479d15b 54
hnoons 0:b41e9479d15b 55 // // int rnd = rand()%1000; //generates random integer between 1 and 1000
hnoons 0:b41e9479d15b 56 ////
hnoons 0:b41e9479d15b 57 ////
hnoons 0:b41e9479d15b 58 //// int PIN = id*rnd; //mutliplies id and random number
hnoons 0:b41e9479d15b 59 // lcd.printf("YOur PIN is: %d", id); //displays pin
hnoons 0:b41e9479d15b 60 // //sndpn = PIN; //sets sndpn to pin (to send to computer for comparison)
hnoons 0:b41e9479d15b 61 // wait(2); //shows for 20 seconds (to allow to write down -- shorter maybe)
hnoons 0:b41e9479d15b 62 // lcd.cls(); //clears screen
hnoons 0:b41e9479d15b 63
hnoons 0:b41e9479d15b 64
hnoons 0:b41e9479d15b 65 //if (flag) {led = 0;} //led to say pc in use
hnoons 0:b41e9479d15b 66 // else {led = 1;}
hnoons 0:b41e9479d15b 67
hnoons 0:b41e9479d15b 68
hnoons 0:b41e9479d15b 69
hnoons 0:b41e9479d15b 70