Understanding the language, error messages, etc.
by Sushi » Fri Nov 07, 2014 3:44 pm
I'm trying to replicate r0d0t's Ghost Detector in which he used the I2C ports as direct inputs. I'm using analogRead(27) and analogRead(28) to gather information from the I2C, but I get a lot of static. That's why I'm unsure I have the proper pins. I used the Gamebuino schematic from the wiki to get the pins 27 and 28. Does anyone know what I'm doing wrong? My code:
- Code: Select all
#include <Gamebuino.h>
#include <SPI.h>
Gamebuino gb;
const DAT = 27;
const CLK = 28;
float DATA = 0;
void setup(){
pinMode(DAT,INPUT);
pinMode(CLK,INPUT);
gb.begin();
gb.titleScreen(F("Ghost Detector"));
}
void loop(){
if(gb.update()){
DATA = analogRead(DAT)/2 + analogRead(CLK)/2;
gb.display.drawRect(0,30,DATA,5);
if(gb.buttons.pressed(BTN_C)){
gb.titleScreen(F("Ghost Detector"));
}
}
}
-
Sushi
-
- Posts: 52
- Joined: Tue Oct 07, 2014 12:12 am
by rodot » Fri Nov 07, 2014 7:01 pm
Did you cut the pull-up jumper to disable it?
-
rodot
- Site Admin
-
- Posts: 1290
- Joined: Mon Nov 19, 2012 11:54 pm
- Location: France
-
by Sushi » Sat Nov 08, 2014 3:37 am
No, I didn't. Would that mean desoldering? If anything, I can't solder to save myself. XD. Also, does my code look okay?
-
Sushi
-
- Posts: 52
- Joined: Tue Oct 07, 2014 12:12 am
Return to Programming Questions
Who is online
Users browsing this forum: No registered users and 80 guests