Most Popular

1500 questions
4
votes
2 answers

Convert Hex to Decimal from signed 2's complement

I am reading data from a meter over dlms protocol and I am getting hex values from there. I want to convert that hex string to signed decimal value. For example - ff9d denotes a value of -99 [reference]. My hex to decimal code is: unsigned int…
Prateek Goyal
  • 175
  • 3
  • 9
4
votes
4 answers

What is the best and most reliable way to detect if a book is pulled out of a book case?

What is the best and most reliable way to detect if a book is pulled out of a book case? I have a book case which I want to mount sensors to so that I can detect when certain books are pulled out, I don't need to know how much, all I need is a…
JensB
  • 151
  • 3
4
votes
1 answer

How to burn the bootloader and upload sketches on ATmega328P U (specifically this model)?

Recently I started to learn embedded electronics and C/C++ and for a couple of days I tried and I am still trying to burn a new ATMega328P U bought from Aliexpress. From what I know new ATMega328P's come with bootloader included, but after I wired…
4
votes
1 answer

Arduino timer interrupts for PID

I'm working on a robotics project where an arduino nano is acting as the motion controller. I'm trying to use a trapezoidal motion profile generator and PID loop to follow that profile, but I found out the motion was quite jerky and I assumed it's…
OM222O
  • 199
  • 1
  • 7
4
votes
1 answer

why is "if" slow?

I am new to the Arduino world and I hope I can find a solution here. The code below functionally works ok. The problem I have is, at line 45 I've inserted an if statement to change dac_value. It is very slow while serial and all that is outside if…
Marius
  • 41
  • 2
4
votes
1 answer

Interrupts Within Critical Statements

I've redone a previous Arduino sketch I posted in which I was having trouble capturing encoder counts within critical statements, having no luck properly attaching and detaching interrupts. I've studied various ISR sketches but haven't been able to…
4
votes
1 answer

How to get variable from callback function?

There is a library davetcc / IoAbstraction. The only library working as expected with my rotary encoder. The problem that on rotation I can only see serial output with position data, but I cannot get these data as some variable value. There is the…
4
votes
3 answers

Programming Arduino Uno R3 to trigger a relay once every 24 hours

I programmed an Arduino Uno R3 to trigger a relay once every 24 hours from the moment it is powered on. I calculated milliseconds and used the function delay(). 24 hours * 60 minutes each hour * 60 second every minute * 1000 milliseconds every…
Felix0004
  • 43
  • 4
4
votes
1 answer

Arduino nano 33 ble vs ble sense. Power consumption, etc

After working with an Arduino Uno at work, I am looking to buy myself a board for some projects/experiments at home. The nano size seems like a great option, especially the one without soldered headers, as it is very flexible and easy to fit in…
qeiynn
  • 43
  • 4
4
votes
1 answer

What is the logic behind Arduino inlining `HardwareSerial::_rx_complete_irq()` for receiving serial data (but NOT `_tx_udr_empty_irq()`)?

Q: What is the logic behind Arduino inlining HardwareSerial::_rx_complete_irq() for receiving serial data (but NOT _tx_udr_empty_irq()), and when is it advisable? From the bottom of the HardwareSerial class in HardwareSerial.h: // Interrupt handlers…
Gabriel Staples
  • 1,369
  • 11
  • 27
4
votes
1 answer

ESP-01 does not run code after Deep Sleep

When using the deep sleep functionality on several ESP-01 boards, the boards require two resets in order to wake up properly (regardless of whether the resets are done by manually bridging the rst pin or by soldering a wire to do it from an…
sassoPera
  • 303
  • 1
  • 10
4
votes
1 answer

MEGA 2560: Simple program - One analogWrite turns off the other

I'm using Windows 10, Arduino 1.8.12 (Windows Store 1.8.33.0) I have an Arduino MEGA 2560 and a red LED connected to pin 4. #define RED 4 #define GREEN 2 void setup() { analogWrite(GREEN, 0); analogWrite(RED, 100); } void loop() { } This…
Mark
  • 197
  • 1
  • 1
  • 8
4
votes
2 answers

How to connect to MQTT broker with TLS?

I have ESP8266 which is connecting to MQTT broker and it is working ok using user+pass with following code: #include #include const char* ssid = "WIFINAME"; const char* password = "WIFI_PASS"; const char*…
iWizard
  • 143
  • 1
  • 1
  • 5
4
votes
4 answers

How can I set up outputs without using digitalWrite?

Consider the following: #define IN1 9 #define IN2 10 pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); void LeftMotor(Direction direction) { digitalWrite(IN1, direction == Forward ? LOW : HIGH); digitalWrite(IN2, direction == Forward ? HIGH :…
OrElse
  • 57
  • 1
  • 1
  • 7
4
votes
2 answers

Digispark clone not recognised when plugged in

When I plug in my digispark clone the computer doesn't make any sounds or some kind of acknowledgement that it has been plugged in. Anyone know why this may be or is it just a dodgy clone?
davidbrok5
  • 41
  • 1
  • 1
  • 2