Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- 59340500018
- Date:
- 2017-11-22
- Revision:
- 0:c3549f40bdba
File content as of revision 0:c3549f40bdba:
#include "mbed.h"
//------------------------------------
// Hyperterminal configuration
// 9600 bauds, 8-bit data, no parity
//------------------------------------
Serial bt(D8, D2);
AnalogIn analog_value(A1);
BusOut segment(D3,D4,D5,D7);
int main()
{
uint8_t state_menu=0;
uint8_t state_show=0;
uint8_t state_exit =0;
uint8_t data;
//myled = 0;
bt.readable();
bt.printf("ASevenZ");
while(1) {
if(state_show == 0) {
bt.printf("************\n");
bt.printf(" Menu \n");
bt.printf("************\n");
bt.printf("1.Segment Function\n");
bt.printf("2.Read VR\n");
state_show =1;
}
if(bt.readable()) {
data = bt.getc();
bt.printf("\n");
state_show =0;
state_exit =0;
switch(data) {
case '1':
do {
if(bt.readable()) {
data = bt.getc();
if (data=='s'){
segment = 0;
state_exit =1;
break;
}
segment = data;
bt.printf("data: %d\n", data);
state_menu = 0;
}
}
while(state_exit == 0);
bt.printf("break\n");
break;
case '2':
do {
if(bt.readable()) {
data = bt.getc();
if (data=='s'){
bt.printf("\n");
state_exit =1;
break;
}
}
float VR = 0;
VR = analog_value.read();
VR = VR * 3.3f;
bt.printf("VR: %.2f \n",VR);
}
while(state_exit ==0);
bt.printf("\n");
break;
default:
bt.printf("plz select 1 or 2 \n");
bt.printf("\n");
break;
}
}
}
}