test

Dependencies:   mbed MMA8452Q

Fork of HelloWorld by Simon Ford

main.cpp

Committer:
vincentlabbe
Date:
2017-08-30
Revision:
4:a38ef4c242ef
Parent:
3:8494c3f7108d
Child:
5:01729ebe170e
Child:
12:e509487ee82a

File content as of revision 4:a38ef4c242ef:

#include "mbed.h"              
 //hello
Serial pc(USBTX, USBRX); // tx, rx
I2C comI2C(p9,p10);
// Communication I2C
int main() {
    int degree = 3;
    while(1){
        
    pc.printf("test avant read");
    comI2C.start();
    comI2C.read(1);
    comI2C.stop();
    pc.printf("test apres read");
    
    pc.printf("degree = %d", degree);
    wait(2);
    }
}


/* communication SPI 
Serial pc(USBTX, USBRX); // tx, rx
SPI acc(p11,p12,p13);
DigitalOut cs(p14);
int main() {
    while(1){
    int nombre = 0;
    pc.printf("Entrez un nombre de 4 chiffres : ");
    pc.scanf("%d", &nombre);
    pc.printf("Votre numero entrez est le : %d", nombre);
  
    cs = 0;
    acc.write(nombre);
    cs = 1;
    wait(0.2);
    cs = 0;
    wait(1);
    }
}*/
 /*
Serial pc(USBTX, USBRX); // tx, rx
Serial mc(p13,p14);
int main() {
    
    int nombre = 0;
    pc.printf("Entrez un nombre de 4 chiffres : ");
    pc.scanf("%d", &nombre);
    pc.printf("Votre numero entrez est le : %d", nombre);
    mc.printf(nombre);
}
 */


/*
DigitalOut myled(LED2);

int main() {
    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}
*/