Questions tagged [c]

C is a procedural programming language which is widely used in embedded systems. PLEASE NOTE: Arduino is typically programmed in C++, not C.

Filter by
Sorted by
Tagged with
0
votes
3answers
6k views

How to communicate with ESP8266 ESP01 by sending data through softwareserial on Arduino Uno?

I am able to send AT commands when connecting to the software through the TX/RX pins (1, 0) and the ESP01 communicates perfectly. However, as soon as I start doing that same thing with code I can't ...
1
vote
2answers
261 views

Unable to read data with 16 serial clock cycles

I am trying to read data from an AD7314 Temperature Sensor that is connected to an Arduino Uno and output that value onto 6 LEDs also connected to the Arduino Uno board. From the image below, the ...
0
votes
1answer
636 views

Why does void loop() stop after some samples?

I am not getting any compile time error. After some samples of data void loop() stops executing. Please let know what the problem is. Below is my code. Thanks and regards Thippeswamy #include<SPI....
0
votes
1answer
2k views

SPI Temperature sensor interface with Arduino Uno

I want to interface with an AD7314 Temperature Sensor. I want to only read the temperature value from the sensor and output the value on to 8 LEDs connected to the Arduino. But so far I have not been ...
0
votes
1answer
146 views

Not clear code procedure in Arduino wire library

The application code of sparkFun, has the following line which is difficult to understand. It's requested 6, because it's requesting 6 bytes for HMC5883L module. Wire.requestFrom(address, 6); if(6&...
0
votes
1answer
31 views

Is this a good function for I2C receive?

I'm trying to fix my I2C code: Is the following function correct because it has multiple returns. I don't know if that would work. uint8_t I2C_rx(uint8_t ack_rx) { uint8_t i; if (ack_rx) ...
0
votes
1answer
2k views

Checksum is wrong - Air Quality Monitoring Station PMS5003, BME280 | Code review

I working at air quality station. I measure particulate matter with PMS5003 and meteorological parameters with BME280. Everything seems to work just fine, but sometimes program hangs on checksum ...
0
votes
2answers
542 views

Difference between ISR and other functions in AVR twi library

I was studying the ISR for twi and I want to know how is it working. I have two questions about the code handling for ISR and the other functions and what they do exactly: My first question is about ...
0
votes
2answers
391 views

Speed measurement from lidar sensor for automatic braking system

For a school project I have been working on a system that will automatically brake when there is danger. Only the requirements are more strict (safety) than just using a ping sensor and detecting a ...
0
votes
1answer
5k views

Why using static volatile for variables and only static for arrays in TWI library?

I want to know why to declare variables with static volatile and arrays with only static in TWI library? For example; static uint8_t twi_masterBuffer[TWI_BUFFER_LENGTH]; static volatile uint8_t ...
0
votes
1answer
1k views

Integer array definitions: Length

I'm defining a variable as integer and want to use thati int specLength = 17; int spec[specLength-1]; When I do this, I get the following error message: TestProgram:34: error: array bound is not ...
0
votes
2answers
338 views

Why it's not possible to manipulate the TWSR directly? [closed]

I think I forgot the reason for this SFR manipulation in microcontrollers; like, checking the TWSR in twi. The technique for checking the values of the TWSR is by masking it with another variable or ...
0
votes
1answer
1k views

Send events to Azure IoT Hub combined with deep sleep mode

I use a Node MCU ESP8266. I have a working C app sending temperature and humidity sensor data to Azure IoT Hub continuously. I see events/messages coming in at Azure. Now I'd like the app to only ...
0
votes
2answers
4k views

Max length of char arrays?

I'm running the following Sketch on my Arduino Uno: const boolean verbose = true; void debug(const char *s){ if(verbose){ char buf[8 + sizeof(s)] = "[DEBUG] "; strcat(buf, s); ...
-3
votes
2answers
183 views

How to send message from one embedded system to another embedded system like in cars, from one car to another? [closed]

I want to send message from one embedded system to another embedded system, like from one car to another without using phone number. just turn on the wifi.. connect and send message. There are ways to ...
0
votes
1answer
638 views

Arduino program to Blink L LED when input matches a set pattern

I have written a code that is supposed to blink the LED on PB5 pin, when a sequence of input matches a 4 digit password input from a keypad.But the program doesn't appears to be working as expected. ...
0
votes
1answer
168 views

Equivalent to POSIX mmap() in AVR-libc

Is there an similar function in AVR-libc/Arduino C++ to mmap()? I'm looking for a way to place machine code in memory at runtime and make it executable.
2
votes
4answers
1k views

How to get elapsed seconds since Jan 1, 1970?

I am building a time-critical system using Arduino. Is there any way to get the elapsed seconds like time.h of C in Arduino? I tried time(NULL) but it returns 0. Then moved forward to use now() in ...
0
votes
2answers
78 views

Power Measurement

I am trying to develop a system that reads the amount of power consumption from my load. Here is how my setup looks like; The led represents a 5W and 12V light bulb(I was unable to get this in my ...
0
votes
2answers
3k views

Arduino UNO + Ethernet Shield + LCD + RFID but RFID doesn't work

I've been working to a project that uses arduino for RFID but when connected to ethernet shield, the RFID seems to not read any card tapped to sensor but the LCD seems to do fine. Here's the code I ...
7
votes
6answers
16k views

how fast does loop() run in Arduino

Hi I am using Arduino Nano to gamify my experience on Unity3D. I know that Update() in Unity3D runs every frame per second but I because I'm not an electronics guy I don't know how loop() function ...
0
votes
3answers
2k views

strcat appending multiple times when called in loop

The strcat function is working fine when called for the first time but when the broker goes down and it's attempting to reconnect it is appending the value twice. I am not able to figure out the ...
1
vote
1answer
487 views

Unknown type name 'IRsend'

In the C file in simplesample_mqtt.c, which connects Arduino to the Azure IoT hub, I need to use the IRsend and IrRemoteESP8266 libraries to send an infrared signal with Azure IoT hub. #include <...
2
votes
3answers
193 views

Arduino Mega PWM doesn't work in C Code

Why such horrible Arduino's Mega PWM doesn't work?? Below is my code. I try to set Fast PWM 8-bit to dim and light up a LED connected to OCR1A Pin. I try to do it in C language, completelly without ...
4
votes
3answers
1k views

Arduino port relocation (PORTD to PORTB)

So I'm trying to connect the chip with an 8-bit data bus. All works good, but... Arduino Uno uses D0 and D1 for serial TX/RX (USB connection with PC). When I try to open a serial connection (on ...
1
vote
2answers
105 views

Preprocessing problem

I've a little problem, I'm trying to create a library with processor variables for tune it. So in .ino I declared my preprocessor var, but preprocessor variables appear not defined in my library. (...
1
vote
0answers
193 views

HMC5883L stops reading when x-axis value get to positive value

I've been looking for a solution for this problem for quite a time I tried different I2C libraries; like, I2C master library using hardware TWI interface * Author: Peter Fleury But the same ...
3
votes
2answers
550 views

Millisecond timestamp (13 digits) in Arduino

How can I store a 13 digits int in Arduino? For example, current timestamp is: 1500666822235 An uint32_t can only hold 10 digits max. 64 bits integer does not seem to be supported on RFduino.
0
votes
1answer
576 views

MIDIUSB - Why is the command put twice?

Consider this function: void noteOn(uint8_t pitch) { midiEventPacket_t noteOn = {0x09, 0x90 | 9, pitch, 127}; MidiUSB.sendMIDI(noteOn); } midiEventPacket_t is defined as: typedef struct { ...
0
votes
2answers
115 views

character input for an integer variable? [duplicate]

Im trying out the code found here , let me quote the section of code that bothers me. // set pin numbers for switch, joystick axes, and LED: const int switchPin = 2; // switch to turn on and off ...
-1
votes
2answers
3k views

Arduino UNO UART coding in pure C

Below is a simple USART code for ARDUINO written in Pure C. But due to uknown(in reference to me) reasons, the code is not provicing desired output. Can someone point out the error in the code. I ...
3
votes
2answers
1k views

Function pointer or abstract class? [closed]

I need to implement callback in my C++ library. The "proper" C++ way of doing it would be to create an interface (or pure abstract class) and pass it to interested party. I'm wondering though, would ...
1
vote
1answer
20k views

Global variables with C++ in multiple files

I'm not a C++ programmer (but I have used regular C code for implementing low-level machine language equivalent SW for some time), and after trying to modify an existing cC+ program to do what I need (...
1
vote
1answer
1k views

How to interface OV5640 to Arduino Mega using Embedded C? [closed]

I am trying to interface a OV5640 camera module to Arduino Mega 2560 in Eclipse IDE using C language . However I am not able to figure out the registers that need to be initialised , for the camera to ...
0
votes
2answers
305 views

Power ON/OFF a car using Arduino with IR remote control

I'm trying somehow to power OFF the car when the song plays using Arduino using Infrared (IR) Remote. I decided to play a song (SuperMario) using a Buzzer and when I press the Power ON button works ...
0
votes
1answer
150 views

Avoid overflowing of counter

I have a global uint32_t that keep tracks of used Bytes: uint32_t usedBytes; int bytesWritten; byteWritten = myFile.print(data, FILE_WRITE); if (byteWritten > 0) { usedBytes += bytesWritten; } ...
3
votes
2answers
614 views

Problem with using pure C code to program default UART (UART0) in Arduino Mega

Can I code default serial port in Arduino Mega (USART0, I assume) in pure C? I mean to set up it and configure directly by ATmega's registers? I'm asking because I'm trying to do it and I have a ...
0
votes
1answer
1k views

HMC5883L not working in continuous mode!

I'm just starting with the HMC5883L, I'm writing my code with C and also my own I2C library. I noticed that the values on the Arduino IDE's serial monitor are constant. Then I developed a function ...
2
votes
1answer
878 views

Pause in the program for some time

I have a variable timeInSec which records the time as loop begins. It is defined as timeInSec = millis();. I have two conditions. If (timeInSec - lastRun)< 5 (that is 5 sec) , the first condition ...
0
votes
1answer
226 views

Reading HMC5883L hex values in 2's compliment C code

I want to develop my C code for HMC5883L. I have 2 questions for my current code development. My first question is: But what I found in the datasheet is that the values are in the 2's compliment, so ...
0
votes
2answers
112 views

Overflow in bit calculation [closed]

I'm having a double buffer to write data from sensors to SD card. inBuf points to the buffer that are written into (from sensors). The other buffer write data to SD card. char buffer[2][BUFLEN]; ...
0
votes
1answer
2k views

Is Fastled.io library suitable for SMD50500 led strip?

I was looking for a ready to use library to control my SMD5050 color led strip, and I stumbled across FASTLED.IO library , but after reading trough their website I didn't find anywhere the support for ...
1
vote
0answers
65 views

Odd RGB matrix behavior while using shift registers

so I'm playing around with an 8x8 RGB matrix using a 74HC595 shift register for each of the colors. I've done this before with single color matrices and everything worked fine, but here I'm getting ...
1
vote
1answer
385 views

Cannot obtain reading from meter (Modbus)

I have a system in which I am taking readings from a meter and processing it through an Arduino Nano. My code looks as follows: #include <SoftwareSerial.h> #define SerialControl 7 #define ...
3
votes
1answer
270 views

Understanding how methods and pointers inside a function work

After this question i starteted going deep with the theory, and started studyng step-by-step with the "Beginning C, for Arduino " Jack Purdum. I finished to study the functions chapter, but i still ...
2
votes
2answers
1k views

Firmata: how to set a particular pin to high on boot?

I'm working on a project that use J5, so is using the standard firmata, this project is using an opto 4 channel relay, when the board is booting the pins state are set to low, so as soon as I power ...
1
vote
1answer
92 views

Can't send Data to LCD1602 with I2C

I've been doing fine with my LCD1602 I2C configuration but I discovered that command and data functions are the same even though I change the RS command/data bit, but the result is the same. This is ...
0
votes
1answer
95 views

Communication between Arduino and raspberry Pi

So I am working on a ground surveillance robot using Arduino for coding the Gps, motors and ultrasonic sensors and coding in raspberry Pi for facial recognition but now what I want to do is when my ...
0
votes
1answer
107 views

How to keep a specific bit set all the time for bit masking I2C operations?

I've been working on I2C and I learned how to initialize, send and receive with I2C communication protocol. Next, I wanted to run the LCD1602 I2C adapter. But the module has a different bit masking, ...
2
votes
3answers
1k views

Shift Register on ATMEGA328p

I want to learn more about the shiftout function used with Arduinos and used the implementation with my ATMEGA328p. The Setup This is the original shiftout function used in Arduino Programming, ...

1 2 3
4
5
9