Hot answers tagged

4

The problem is, that you are filling up the Serial buffer rather fast, because you try to send ASCII numbers every 10ms at only 9600ms. When the buffer is full, Serial.println() will wait, until there is enough space free in the buffer for the current data. That makes your loop lasting significantly longer. In that case the time, where the time is exactly 10 ...


4

The following code will pause (Give some delay) when it runs for the first time and also when you press the button. void loop() { static int status = true; if(status){ //Pause delay(15); status=false; return; } if(digitalRead(switch_pin) == LOW){ digitalWrite(led_green_pin,LOW); digitalWrite(led_red_pin,HIGH); ...


3

There's two problems here. First, you don't enter "234", you enter "2" followed by "3" and finally "4". Your really small timeout doesn't give the digits enough time to arrive. Second, your line ending is being received and interpreted as "not a number" which is returned as 0 by .toInt(). What you need to do ...


3

There are a couple of issues here. One of them has already been raised in a comment: int main() { - ddrB = (port_type) 0x20; + *ddrB = (int8_t) 0x20; while(true) { The more serious issue is in the command line you used to compile the program. When compiling for an Uno, you should add the option -mmcu=atmega328p. This way the compiler ...


2

your logic is just tricky to confuse. It is repeatable because along as you not change the if logic, the code is going to run till it displays 150. then it will stop. You can also check the same behaviour here Once the time difference is not exactly equal to 10, the if part will not be executed. Hence, the prevtime will not catch up with the newtime anymore. ...


2

Try strptime from the time.h. void setup() { struct tm tm = {0}; char buf[100]; // Convert to tm struct strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm); // Can convert to any other format strftime(buf, sizeof(buf), "%d %b %Y %H:%M", &tm); Serial.printf("%s", buf); } void loop(...


1

When working with Arduino, cplusplus.com is your friend. Scroll down and look on the left side under (string.h). Lot's of great char functions there. Other useful functions such as iota() - cplusplus.com. Here's one way to accomplish the parsing of the input data. // Sketch uses 2064 bytes (6%) of program storage space. // Global variables use 323 bytes (15%)...


1

Servo8Bit and ATTiny13(A) I had a look at the Servo8Bit and had pretty much the same thoughts on this as Edgar Bonet in his comment: Servo8Bit relies on an 8-bit timer, and the ATtiny13A does have an 8-bit timer. It should not be too hard to port this library to that micro. Study the source code, then study the datasheet of the tiny13A (mostly the chapter ...


1

You are on the track, but it needs some adjustments: template < typename datatype> class Device_Handler { // a class to handle devices public: virtual void write_to_device(datatype *send_data)= 0; // write data to device virtual void read_from_device(datatype *store_location)= 0 ; // read data from device to location ...


1

The C library function atoi() will do that for you


Only top voted, non community-wiki answers of a minimum length are eligible