Diana Saveh
/
led
Library A: LED library to controll the led on the Happy Gecko.
main.cpp
- Committer:
- diana_s
- Date:
- 2018-02-12
- Revision:
- 1:55b5e6d28fb3
- Parent:
- 0:3cabc617d433
File content as of revision 1:55b5e6d28fb3:
// Toggle a LED #include "mbed.h" /* Uppgift 1 DigitalOut led(PF4,1); int main() { while(1) { led = 1; wait(1); led = 0; wait(1); printf("Hello World"); } } */ //upgift 2.2 //I2C getTemp(PD6, PD7); //The sensor’s power supply //DigitalOut sensor_en(PC8); // GPIO pin PC8 connected to the sensor /* int main() { sensor_en = 1; // enable power supply wait(0.1); // give the sensor some time to start up int addr = 0x80; char cmd = 0xE3; char data[2]; //store data while (1) { getTemp.write(addr, &cmd, 1);//Master wait(0.1); getTemp.read(addr, data, 2);//Slave wait(0.1); float temp_code; temp_code =((int16_t) data[0] << 8 | data[1]); temp_code = ((175.72*temp_code)/65536)-46.85; printf ("%f\n", temp_code); } } */ //Note: The SDA pin of the sensor is connected to PD6, the SCL pin is connected to PD7. //Note: Remember that I2C addresses are only 7-bit long and therefore the address listed in // the datasheet needs to be shifted by one position to the left.