Majordhome V1.0

Dependencies:   MD25 TextLCD mbed HTU21D PixyLibrary VCNL40x0

Revision:
0:11ba3658cd5e
Child:
1:38ebbd3ed083
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Mar 30 16:47:21 2015 +0000
@@ -0,0 +1,57 @@
+#include "mbed.h"
+#include "MD25.h"
+#include "mbed.h"
+#include "TextLCD.h"
+//100kHz clock, addr B0, reg 0=speedl, 1=speedr (0 (Full Reverse) 128 (Stop) 255 (Full Forward). 15=mode (set to 0 default)
+ 
+MD25 i2c(PB_9, PB_8); //Dont forget the 2.5 k pullup on both wires when USB is not connected 
+TextLCD lcd(D2, D3, D4, D5, D6, D7,TextLCD::LCD20x4); // rs, e, d4-d7
+//*** DEBUG CONSOLE PARAMETERS ***//
+
+DigitalIn bouton (USER_BUTTON);
+DigitalIn cap_arret(PA_9);
+
+
+int main() {
+int flag=0;
+bouton.mode (PullUp);
+
+Serial debug(USBTX,USBRX);
+debug.format(8,Serial::None,1); 
+debug.baud(115200); 
+i2c.setMode(0); // MODE 0, 0=marche arriere 128=stop 255=marche arriere vmax
+i2c.setCommand(32); // 0x20 reset encoders
+i2c.setCommand(50); // 0X32 Disable time out
+//i2c.setCommand(48); // 0X32 Disable speed regulation
+lcd.printf("Majord'home ON!\n");
+ //   while(PB_1==1){
+i2c.setSpeedRegisters(0,0);
+
+//i2c.setCommand(32); // 0x20 reset encoders
+
+//lcd.printf("Majord'home OFF!\n");
+
+
+//}
+  while(flag==0) {
+      cap_arret.read();
+      if(cap_arret==0){
+          i2c.stopMotors();
+          lcd.printf("Arret ON");
+          lcd.locate(0,0);
+          }
+          else if(bouton==0){
+              i2c.stopMotors();
+              lcd.printf("Arret ON");
+              lcd.locate(0,0);
+              flag=1;
+              }
+              else{
+                  i2c.setSpeedRegisters(60,60);
+                  lcd.printf("Arret OFF");
+                  lcd.locate(0,0);
+                  }
+
+      
+      } 
+}
\ No newline at end of file