Ejemplo n.º 1
0
// main()
//
// This function reads the sensors and outputs a string of data
//
// Parameters: none
// returns: The string of outputs from all sensors
int main(void){
	double x, y, z, temperature, humidity, leftVoltage, rightVoltage;
	char outputString[200];
	
	// Create all of the sensor objects
	ADXL345 accelerometer(1);
	HIH6130 tempHumidity(1);
	Analog leftSound(0,0);
	Analog rightSound(1,0);

	// Read accelerometer
	x = accelerometer.GetX();
	y = accelerometer.GetY();
	z = accelerometer.GetZ();

	// Read Temperature / Humidity
	temperature = tempHumidity.GetTemperature();
	humidity = tempHumidity.GetHumidity();

	// Read left sound sensor
	leftVoltage = leftSound.GetVoltage();

	// Read right sound sensor
	rightVoltage = rightSound.GetVoltage();

	sprintf(outputString, "X, Y, Z, Temperature, Humidity, LeftSound, RightSound\n%4.2f,%4.2f,%4.2f,%4.2f,%4.2f,%4.2f,%4.2f\n", x, y, z, temperature, humidity, leftVoltage, rightVoltage);
	std::cout << outputString;

	return 0;
}
Ejemplo n.º 2
0
void loop (){
  //WHAT MODE
  if (digitalRead(buttonApin) == LOW){
    while (digitalRead(buttonApin)){
     //avoids flipping modes rapidly
    }
     if (mode == 1){mode=2;}
     else if (mode == 2){mode=3;}
     else if (mode == 3){mode=1;}
     else mode = 1;
  }
  //ACCELEROMETER
 if (mode == 1) {
    accelerometer();
 }
 //LAP TIMER 
 if (mode == 3){
   runTimerv3();
 } 
 if (mode == 2){
   two_temp_meter(); 
 }

 
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
    int result = 0;

    QGuiApplication *app = SailfishApp::application(argc, argv);
    QQuickView *view = SailfishApp::createView();

    qmlRegisterType<PlotWidget>("harbour.messwerk.MesswerkWidgets", 1, 0, "PlotWidget");
    qmlRegisterType<SatellitePosWidget>("harbour.messwerk.MesswerkWidgets", 1, 0, "SatellitePosWidget");
    qmlRegisterType<SatelliteStrengthWidget>("harbour.messwerk.MesswerkWidgets", 1, 0, "SatelliteStrengthWidget");

    QTimer refreshTimer;

    Accelerometer accelerometer(false);
    Gyroscope gyroscope(false);
    Magnetometer magnetometer(false);
    Rotation rotation(false);
    Light light(false);
    Proximity proximity(true);
    SatelliteInfo satelliteinfo;
    Position position;

    // connect not self-refreshing sensors to the global timer
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &accelerometer, SLOT(refresh()));
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &gyroscope, SLOT(refresh()));
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &magnetometer, SLOT(refresh()));
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &rotation, SLOT(refresh()));
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &light, SLOT(refresh()));

    QString qml = QString("qml/%1.qml").arg("Messwerk");
    view->rootContext()->setContextProperty("accelerometer", &accelerometer);
    view->rootContext()->setContextProperty("gyroscope", &gyroscope);
    view->rootContext()->setContextProperty("magnetometer", &magnetometer);
    view->rootContext()->setContextProperty("rotationsensor", &rotation);
    view->rootContext()->setContextProperty("lightsensor", &light);
    view->rootContext()->setContextProperty("proximitysensor", &proximity);
    view->rootContext()->setContextProperty("satelliteinfo", &satelliteinfo);
    view->rootContext()->setContextProperty("positionsensor", &position);
    view->rootContext()->setContextProperty("settings", &(Settings::instance()));
    view->setSource(SailfishApp::pathTo(qml));
    view->show();

    refreshTimer.start(100);

    result = app->exec();

    delete view;
    delete app;

    return result;
}
Ejemplo n.º 4
0
void loop (){
  //WHAT MODE
  LCDSerial.print(mode);
  if (digitalRead(buttonApin) == LOW){
    while (digitalRead(buttonApin)){
     //avoids flipping modes rapidly
    }
     if (mode == 1){mode=2;}
     else if (mode == 2){mode=3;}
     else if (mode == 3){mode=4;}
     else if (mode == 4){mode=5;}
     else if (mode == 5){mode=6;}
     else if (mode == 6){mode=7;}
     else mode = 1;
  }
  //ACCELEROMETER
 if (mode == 2) {
    accelerometer();
 }
 //LAP TIMER 
 if (mode == 6){
   runTimer();
 } 
 if (mode == 1){
  temp_meter(); 
 }
 if (mode == 3){
  boost_meter(); 
 }
 if (mode == 4){
  temp_boost_meter(); 
 }
 if (mode == 5){
   two_temp_meter();
 }
 if (mode == 7){
   usb_logger();
 }
 
}
Ejemplo n.º 5
0
String GY85::getFormattedDataRow() {
  String accelerometerValues = accelerometer();

  delay(10);
  String gyroscopeValues = gyroscope();

  delay(10);
  // in degree Celsius (°C)
  String temperatureValue = temperature();

  delay(10);
  // heading is the angle between the direction in which
  // the sensor nose is pointing
  // and the magnetich north as the reference direction
  // it is provided in degrees (°) in the range 0-360
  String headingValue = heading();

  String dataRow = String();
  dataRow = accelerometerValues + DATA_SEPARATOR + gyroscopeValues + DATA_SEPARATOR + temperatureValue + DATA_SEPARATOR + headingValue;

  return dataRow;
}
Ejemplo n.º 6
0
int main(void) {
  int i;
  int reading1;
  int reading2;
  int address;
  int test_array[100];

  for(i=0;i<100;i++) {
    motor(0,i);  //spin the left motor forward
    motor(1,i);  //spin the right motor forward
  }

  i=0;
  while(i>-100) {
    motor(0,i);  //spin the left motor backwards
    motor(1,i);  //spin the right motor backwards
    i--;
  }

  i=50;
  set_servo(0,i);  //set servo motor 0 to move to 50 degrees
  set_servo(3,i);  //set servo motor 3 to move to 50 degrees

  delay_milliseconds(100);  //pause 100 milliseconds
  delay_seconds(1);  //pause 1 second

  lcd_clear();
  lcd_cursor(0,0);
  printf ("Test1\n"); //the LCD will be 8x2 (8chars x 2lines)
  printf ("Test2\n");

  reading1 = analog(0);  //get a reading from analog pin 0
  reading2 = analog(5);  //get a reading from analog pin 5
  reading1 = digital(0);  //get a reading from digital pin 0
  reading2 = digital(1);  //get a reading from digital pin 1

  if (reading1 > 100) {
    printf ("%d\n", reading1);
  }

  reading1 = accelerometer(0);  //read x-axis
  reading2 = accelerometer(1);  //read y-axis
  reading1 = accelerometer(2);  //read z-axis

  reading1 = battery_voltage();  //battery voltage

  reading1 = read_serial_port();  //get a byte from the serial port
  write_serial_port(reading1);  //send a byte on the serial port

  led1(1);  //turn on on-board led1
  led1(0);  //turn off on-board led1

  reading1 = read_ir();  //get a reading from the IR receiver

  reset();  //reset the board

  write_eeprom(address, reading1);  //write a value to the non-volatile eeprom (these values will be stored across resets)
  reading1 = read_eeprom(address);  //get a reading from the non-volatile eeprom

  reading1 = button(); //read the state of the on-board button

  return 0;
}