Search found 24 matches

by LORDHADES
Sat Nov 28, 2020 12:37 pm
Forum: General discussion
Topic: [Solved] I need to return a single value from incoming serial data...
Replies: 37
Views: 19261

Re: I need to return a single value from incoming serial data...

If the serial monitor is empty that means that no data is received fron the scale. This is why you see "?" in monitor for the first version, too. Any solutions Sir? int inByte; void setup() { Serial.begin(9600); Serial2.begin(9600); } void loop() { if(Serial2.available()>0) { inByte = Ser...
by LORDHADES
Sat Nov 28, 2020 12:19 pm
Forum: General discussion
Topic: [Solved] I need to return a single value from incoming serial data...
Replies: 37
Views: 19261

Re: I need to return a single value from incoming serial data...

And here a version which outputs data each time the scale send some data, independent on any button. #define NR_BYTES 10 uint8 inBytes[10], inCnt, dataIn; uint32 rxTime; void loop() { uint32 m = millis(); if ((m-rxTime)>20) { inCnt = 0 if (dataIn==1) { dataIn = 0; for (int i=0; i<NR_BYTES; i++) Ser...
by LORDHADES
Sat Nov 28, 2020 12:02 pm
Forum: General discussion
Topic: [Solved] I need to return a single value from incoming serial data...
Replies: 37
Views: 19261

Re: I need to return several values from incoming serial data...

Try this (beside your setup) #define NR_BYTES 10 uint8 inBytes[10], inCnt; uint32 rxTime; void loop() { if (Serial2.received()>=0) // serial data available? { uint32 m = millis(); if ((m-rxTime)>20) inCnt = 0 rxTime = m; if (inCnt>=NR_BYTES) inCnt = 0; inBytes[inCnt++] = Serial2.read(); } if (is_bu...
by LORDHADES
Sat Nov 28, 2020 11:13 am
Forum: General discussion
Topic: [Solved] I need to return a single value from incoming serial data...
Replies: 37
Views: 19261

Re: I need to return a single value from incoming serial data...

Are there always 7 bytes? In which interval are they sent? Each second or once each time you put someting on it? Each Second, I think... Weight on the scale deviates by +or- 2 over time. This is also continuously updated on the serial monitor. "https://www.acurelweighingindia.com/precision-wei...
by LORDHADES
Sat Nov 28, 2020 11:05 am
Forum: General discussion
Topic: [Solved] I need to return a single value from incoming serial data...
Replies: 37
Views: 19261

Re: I need to return a single value from incoming serial data...

The question is what is a "value" returned by the scale? Which format has the value? Is it a single byte or they are several bytes? Can you post a link to the used scale? It is a custom built scale, known as Acurel, brother. It renders value like "000.112" (in Kgs on serial moni...
by LORDHADES
Sat Nov 28, 2020 10:42 am
Forum: General discussion
Topic: [Solved] I need to return a single value from incoming serial data...
Replies: 37
Views: 19261

Re: I need to return a single value from incoming serial data...

Try this: void loop() { if (Serial2.received()>=0) // serial data available? inByte = Serial2.read(); if (is_button_press==LOW && !digitalRead(buttonPin)) // button pressed? { is_button_press = HIGH; digitalWrite(ledPin, LOW); // turn LED on Serial.write(inByte); delay(debounce_delay); } if...
by LORDHADES
Sat Nov 28, 2020 6:18 am
Forum: General discussion
Topic: [Solved] I need to return a single value from incoming serial data...
Replies: 37
Views: 19261

Re: I need to return a single value from incoming serial data...

I am explaining my requirement again. * I have an electronic scale connected to stm32 via max232. * Stm32 is connected to pc via ftdi. * I'm using arduino ide for programming and i'm using cores and board managers from stm32duino. * I need to print the weight from scale on a thermal printer only onc...
by LORDHADES
Sat Nov 28, 2020 6:06 am
Forum: General discussion
Topic: [Solved] I need to return a single value from incoming serial data...
Replies: 37
Views: 19261

Re: I need to return a single value from incoming serial data...

int inByte; const int buttonPin = PA0; const int ledPin = PC13; int is_button_press = 0; int debounce_delay = 300; void setup() { pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT_PULLUP); Serial.begin(9600); Serial2.begin(9600); } void loop() { is_button_press = digitalRead(buttonPin); if (Serial2...
by LORDHADES
Fri Nov 27, 2020 12:25 pm
Forum: General discussion
Topic: [Solved] I need to return a single value from incoming serial data...
Replies: 37
Views: 19261

Re: I need to return a single value from incoming serial data...

GonzoG wrote: Fri Nov 27, 2020 11:45 am Remove "Serial.available()" from "if".
Serial.available() checks if there are any incoming data in buffer.
If you just want to check it there is active connection on serial, use:

Code: Select all

if(Serial || button!=prev_button)
Loads of thanks brother... :D
by LORDHADES
Fri Nov 27, 2020 10:42 am
Forum: General discussion
Topic: [Solved] I need to return a single value from incoming serial data...
Replies: 37
Views: 19261

Re: I need to return a single value from incoming serial data...

Too bad but not much we can help with, your code is incomplete so we cannot test it. How is the button connected ? What do you do in the setup function? What, if anything, happens when you run the program? int inByte; const int buttonPin = PA0; const int ledPin = PC13; int is_button_press = 0; int ...

Go to advanced search