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.
Communicator.cpp
- Committer:
- noamnahum
- Date:
- 2021-04-11
- Revision:
- 1:f8372f3df8d2
- Parent:
- 0:c2b3b055cc8e
- Child:
- 2:5e42a3c4fd80
File content as of revision 1:f8372f3df8d2:
#include "mbed.h"
Serial pc(USBTX,USBRX);
float Pedal,Thorttle,Speed,Voltage =0; // This variables give DATA
int RPM = 0;
/* Pedal 0 -255
Thorttle 0-255
Speed 0-90
RPM 0-10000
Voltage 0-24 */
int PedalError,ThorttleError,CANError,BSPDError,Shutdowncircuit,Brake =0; // This variables give 0 or 1
int main(){
int i,j,k,z = 0;
int e = 0;
pc.baud(115200);
while(1){
pc.printf("P%.4f\n", Pedal);
pc.printf("T%.4f\n", Thorttle);
pc.printf("b%d\n", Brake);
pc.printf("R%d\n", RPM);
pc.printf("V%.4f\n", Voltage);
pc.printf("S%.4f\n", Speed);
pc.printf("C%d\n", CANError);
pc.printf("t%d\n", ThorttleError);
pc.printf("p%d\n", PedalError);
pc.printf("B%d\n", BSPDError);
pc.printf("s%d\n", Shutdowncircuit);
i++;
j++;
k++;
z++;
e++;
Pedal = i;
Thorttle = i;
RPM = j;
Speed = k;
Voltage = z;
if(i == 255){
i =0;
}
if(j == 10000){
j =0;
}
if (k == 90){
k=0;
}
if (z==24){
z=0;
}
if (e == 1000){
e = 0;
if (Brake == 0){
PedalError= 1;
ThorttleError= 1;
CANError= 1;
Brake= 1;
BSPDError= 1;
Shutdowncircuit = 1;
}
else{
PedalError= 0;
ThorttleError= 0;
CANError= 0;
Brake= 0;
BSPDError= 0;
Shutdowncircuit = 0;
}
}
}
}