Created
November 27, 2012 09:31
-
-
Save barometz/4153333 to your computer and use it in GitHub Desktop.
ES22 week 2 opdr 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* main.c | |
* | |
* Created on: Nov 26, 2012 | |
* Author: dominic | |
*/ | |
#include "RP6ControlLib.h" | |
#include <stdint.h> | |
#include <math.h> | |
#define LINKSVOOR ADC_5 | |
#define RECHTSVOOR ADC_4 | |
#define LINKSACHTER ADC_2 | |
#define RECHTSACHTER ADC_3 | |
uint8_t getObjDistanceLeft() | |
{ | |
float val = readADC(LINKSVOOR); | |
return (uint8_t)(1/(0.09 * val / 204.8 - 0.01)); | |
} | |
uint8_t getObjDistanceRight() | |
{ | |
float val = readADC(RECHTSVOOR); | |
return (uint8_t)(1/(0.09 * val / 204.8 - 0.01)); | |
} | |
int main(void) | |
{ | |
initRP6Control(); | |
initLCD(); | |
showScreenLCD("ES22 W2", "Opdracht 3"); | |
//writeNStringLCD_P("ES22 W2 \nOpdracht 3"); | |
mSleep(400); | |
while (true) { | |
clearLCD(); | |
showScreenLCD("LINKS: ", "RECHTS: "); | |
setCursorPosLCD(0, 7); | |
writeIntegerLCD(getObjDistanceLeft(), 10); | |
setCursorPosLCD(1, 7); | |
writeIntegerLCD(getObjDistanceRight(), 10); | |
mSleep(200); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment