hi everyone,
i have a project im working on and have hit a roadblock so to say.
i am trying to read from a speed radar device and display the speed on a seven segment display.
the radar outputs at 115200 baud; 8 data bits; no parity and the format is: nnn.d[cr][lf]
where n is the whole number of the speed, d is the number to the right of the decimal place
i am using SevSeg library and the harware ports on the mega with a max 232 conversion chip
the problem i am having is i dont know how to get the nnn.d into a dat type i can use with the seven segment library
i am pretty sure the problem is reading the whole ascii string, i believe my code is just grabbing one char at a time
#include "SevSeg.h"
//Create an instance of the object.
SevSeg sevseg;
float output;
long previousMillis = 0;
long interval = 1000;
void setup() {
//I am using a common anode display, with the digit pins connected
//from 2-5 and the segment pins connected from 6-13
sevseg.Begin(0,2,3,4,5,6,7,8,9,10,11,12,13);
//Set the desired brightness (0 to 100);
sevseg.Brightness(100);
Serial.begin(115200);
Serial2.begin(115200);
}
void loop() {
// read from port 2, send to port 0:
if (Serial2.available()) {
output = Serial2.read();
Serial.write(output);
}
{
//Update the number to be displayed, with a decimal
//place in the correct position.
unsigned long currentMillis=millis();
if(currentMillis - previousMillis > interval) {//sort of delay so it isnt changing the display so fast
// save the last time you blinked the LED
previousMillis = currentMillis;
sevseg.NewNum((output*10),3);
}
{
//Produce an output on the display
sevseg.PrintOutput();
}
}}
i am trying to figure out a way to read the whole string and change it to an variable integer i can use with the seven segment library
i am fairly new to arduino and any help would be much appreciated
thanks in advance