// --------------------------------------------------------------------------------------------
// mini sensor template (example of a sensor sending node)
// designed for the Smart-Its mini sensor board
// --------------------------------------------------------------------------------------------
// last modified: 11.03.2003
// --------------------------------------------------------------------------------------------
// COPYRIGHT (c) 2002, 2003 by Albrecht Schmidt - http://www.comp.lancs.ac.uk/~albrecht/
// Lancaster University, http://www.comp.lancs.ac.uk/
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// --------------------------------------------------------------------------------------------
// developed/improved for various prototypes
// in the Smart-Its Project (http://www.smart-its.org) and
// in the Equator IRC (http://www.equator.ac.uk)
// --------------------------------------------------------------------------------------------
// compiled with
// CCS PCM C Compiler, Version 3.080
// CCS PCH C Compiler
#include "core16.c"
#include "msens_v1.c"
#SEPARATE
#use rs232(baud=115200,xmit=PIN_C6,rcv=PIN_C7)
void print_sensor_data(int counter)
{
short int passiveIrVal, touchVal; // 1bit value for pasive infrared and touch
long lightVal1, lightVal2,
accelXVal, accelYVal,
accelZVal, accelUVal; // 16bit values for light and acceleration
int tempVal; // 8 bit value for temperature
unsigned int accXVal, accYVal,
accUVal, accZVal;; // 8bit acceleration values
// restart watchdog timer
restart_wdt();
// leds on sensor board on
led_on1();
// reset the print buffer for sending via RF
reset_rf_buffer();
printf(to_rf_buffer, "C%i\n", counter);
// read touch sensor and print it over serial and into RF-buffer
touchVal=touch();
printf(to_rf_buffer, "Q%i\n", touchVal);
// read light sensors and print it over serial and into RF-buffer
lightVal1=light1();
lightVal2=light2();
printf(to_rf_buffer,"L%li:%li\n", lightVal1, lightVal2);
// read acceration X and print it over serial and into RF-buffer
accXVal=get_accX();
printf(to_rf_buffer,"X%u\n", accXVal);
// read acceration Y and print it over serial and into RF-buffer
accYVal=get_accY();
printf(to_rf_buffer,"Y%u\n", accYVal);
// read acceration X and print it over serial and into RF-buffer
accZVal=get_accZ();
printf(to_rf_buffer,"Z%u\n", accZVal);
// read acceration Y and print it over serial and into RF-buffer
accUVal=get_accU();
printf(to_rf_buffer,"U%u\n", accUVal);
// read temperature and print it over serial and into RF-buffer
// introduces a 1 second delay!!!
tempVal=temp();
printf(to_rf_buffer,"T%i\n", tempVal);
// print everything in the RF buffer
RF_printf_onNOCD(500);
// and on serial line
printf("%s", rf_buffer);
led_on();
restart_wdt();
}
main() {
int i;
init_core();
led_off();
i=0;
restart_wdt();
init_sensor_board();
while(1) {
restart_wdt();
i++;
print_sensor_data(i);
led_off();
delay_ms(100);
restart_wdt();
led_on();
delay_ms(200);
restart_wdt();
led_off();
delay_ms(100);
restart_wdt();
led_on();
delay_ms(200);
restart_wdt();
led_off();
}
}