Hi all,
I am currently working on a Tricorder project. I am going to use the Nunchuck for navigation and multiple sensors for input. The output will be the 5110 Nokia lcd. I am following the library and code from Adafruit for the LCD and following Wayne and Laynes Nunchuck code and library for the Nunchuck. Being a big noob I was having trouble combining the current sketch I have for printing sensor values to the LCD and the example Nunchuck code. My problem I think is because of the #include and #define lines of code.
here is the code for my sensor values
/*********************************************************************
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
// pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN)
// pin 5 - Data/Command select (D/C)
// pin 4 - LCD chip select (CS)
// pin 3 - LCD reset (RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#include <Wire.h>
#include <Adafruit_MPL115A2.h>
Adafruit_MPL115A2 mpl115a2;
void setup() {
Serial.begin(9600);
mpl115a2.begin();
display.begin();
// init done
pinMode(13, OUTPUT);
// you can change the contrast around to adapt the display
// for the best viewing!
display.setContrast(50);
display.display(); // show splashscreen
delay(2000);
display.clearDisplay(); // clears the screen and buffer
// Tricorder
display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(0,0);
display.println("Tricorder");
display.display();
display.clearDisplay(); // clears the screen and buffer
delay(2000);
// text display tests
display.setTextSize(0.1);
display.setTextColor(BLACK);
display.setCursor(0,0);
display.println("Getting temperature and barometricpressure: ");
display.display();
display.clearDisplay();
delay(2000);
// invert the display
display.invertDisplay(true);
delay(1000);
display.invertDisplay(false);
delay(1000);
}
void loop(){
float pressureKPA = 0, temperatureC = 0;
pressureKPA = mpl115a2.getPressure();
temperatureC = mpl115a2.getTemperature();
display.setTextSize(0.1);
display.setTextColor(BLACK);
display.setCursor(0,0);
display.println("Temp (*C): ");
display.setTextSize(0.1);
display.setTextColor(BLACK);
display.println(temperatureC, 1);
display.setTextSize(0.1);
display.setTextColor(BLACK);
display.setCursor(0,16);
display.println("Barometric Pressure (*KPA): ");
display.setTextSize(0.1);
display.setTextColor(BLACK);
display.println(pressureKPA, 1);
display.display();
display.clearDisplay();
delay(2000);
digitalWrite(13, HIGH);
delay(10);
digitalWrite(13, LOW);
}
void testdrawchar(void) {
display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(0,0);
for (uint8_t i=0; i < 168; i++) {
if (i == '\n') continue;
display.write(i);
//if ((i > 0) && (i % 14 == 0))
//display.println();
}
display.display();
}
and here is the Nunchuck code
/*
Arduino sketch to demonstrate interfacing with a Nintendo Wii Nunchuck. It will print the nunchuck information from P1 every second, to the serial terminal at 9600 baud.
Created by Adam Wolf and Matthew Beckler
Wayne and Layne, LLC - http://wayneandlayne.com/projects/video-game-shield/
Recent updates:
August 18, 2012 - Changed file extension to .ino for Arduino 1.0
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.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <i2cmaster.h>
#include <nunchuck.h>
Nunchuck nunchuck;
void setup()
{
nunchuck.begin(NUNCHUCK_PLAYER_1);
Serial.begin(9600);
}
void loop()
{
nunchuck.update();
Serial.println("Nunchuck values:");
Serial.println("Joystick:");
Serial.print("x: "); Serial.println(nunchuck.joy_x(), DEC);
Serial.print("y: "); Serial.println(nunchuck.joy_y(), DEC);
Serial.println("Accelerometer:");
Serial.print("x: "); Serial.println(nunchuck.acc_x(), DEC);
Serial.print("y: "); Serial.println(nunchuck.acc_y(), DEC);
Serial.print("z: "); Serial.println(nunchuck.acc_z(), DEC);
Serial.println("Buttons:");
Serial.print("c: ");
if (nunchuck.button_c())
{
Serial.println("pushed");
}
else
{
Serial.println("not pushed");
}
Serial.print("z: ");
if (nunchuck.button_z())
{
Serial.println("pushed");
}
else
{
Serial.println("not pushed");
}
delay(1000);
}
If somebody could give me the code before VoidSetup I think I could figure out the rest.
Thanks for the help