Permet de lire et stocker dans une variable publique (en int ou en string) la direction pointee par la girouette WS1080.
Dependencies: mbed GirouetteWD1080
main.cpp@0:a2c4b47bcfd1, 2019-06-29 (annotated)
- Committer:
- Station_Meteo_Laos
- Date:
- Sat Jun 29 16:17:45 2019 +0000
- Revision:
- 0:a2c4b47bcfd1
Permet de lire et stocker dans une variable publique (en int ou en string) la direction pointee par la girouette WS1080.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 1 | #include "mbed.h" |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 2 | #include "GirouetteWD1080.h" |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 3 | |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 4 | DigitalOut myled(LED1); |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 5 | Serial pc(USBTX, USBRX,9600); // tx, rx |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 6 | GirouetteWD1080 girouette(A1); |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 7 | |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 8 | int main() { |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 9 | string p; |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 10 | while(1) { |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 11 | pc.printf("\n"); |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 12 | //Lecture et affichage avec retour d'un string |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 13 | if(girouette.read_string()==true)pc.printf("Direction du vent : %s\n",girouette.direction_string); |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 14 | if(girouette.read_string()==false)pc.printf("Erreur de lecture : %s !\n",girouette.direction_string); |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 15 | //Lecture et affichage avec retour d'un int |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 16 | if(girouette.read_int()==true)pc.printf("Direction du vent : %u\n",girouette.direction_int); |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 17 | if(girouette.read_int()==false)pc.printf("Erreur de lecture : %u !\n",girouette.direction_int); |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 18 | pc.printf("\n"); |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 19 | } |
Station_Meteo_Laos | 0:a2c4b47bcfd1 | 20 | } |