Questions tagged [programming]

The process of designing and writing source code as part of a program (or sketch) for Arduino. For questions about uploading code to an Arduino board, use the [uploading] tag instead.

Filter by
Sorted by
Tagged with
2
votes
1answer
40 views

`LOW` being defined as `0` and `HIGH` being defined as `1` - is this a part of external specification?

Arduino.h defines LOW as 0x0 and HIGH as 0x1. Does the Arduino API intend to expose that fact? Does it guarantee that this will always be that way? In other words, what is the intended purpose of ...
0
votes
2answers
45 views

How to write a function to return matrix?

I need a function to return a 2x2 rotation matrix, something like: float matrix(float phi){ float R[2][2] = { {cos(phi), -sin(phi)}, {sin(phi), cos(phi)} }; return R; } But ...
0
votes
1answer
53 views

nodeMCU - 2 loops at a time - one continuously and second every 10 seconds

i have nodeMCU v3(esp8266) so i need to make 2 checks 1 check is the pin D1 which needs to be done continuously and another check is web link check every 10 seconds, problem is coz when i put delay ...
1
vote
1answer
1k views

'Var' does not name a type!

I don't have much experience in C++ programming. I'm getting this error 'z' does not name a type!!! which I have't seen in MATLAB or python... What's wrong??? It is so simple!!! float x=10; float ...
1
vote
1answer
116 views

STM32YYXX chip series is not defined in boards.txt

The STM32YYXX chip series is not defined in boards.txt? How can I solve this? I am using Windows 10 with Arduino IDE 1.6.6
0
votes
0answers
101 views

Fastest way to convert binary string to a number?

I am using a Teensy 3.2 board as control logic for an ADC that I am building for teaching purposes. Currently, I am employing an attachInterrupt() to detect the rising edge of an external clock pulse ...
0
votes
1answer
39 views

Help with coding Arduino Nano to run fan through slide switch at specific intervals

I’m trying to use Arduino Nano to run my 5 V PC fan, which, I know it sounds crazy, it’ll be mounted on a piece of Tupperware that’ll control the airflow through it via the fan. However I have no ...
4
votes
1answer
91 views

How do you combine 2 different sketches together

(Before you down-vote this, note that it is a "ringer" to answer a FAQ, with a self-answer.) This question comes up all the time. How do you combine 2 different sketches together? Say I have a sample ...
1
vote
1answer
56 views

Reading text line by line from SD

Why does the following code return this error? How can I make this work? Error: exit status 1 invalid conversion from 'const char*' to 'char' [-fpermissive] #include "FS.h" #include "SD.h" #...
0
votes
3answers
148 views

Does bool return an int?

I know that for the Arduino (and C in general) that for comparison sake, "false" is 0, while any non-zero integer is "true". The question that I have is does the bool data type "return" a concrete ...
0
votes
1answer
52 views

How do I make a counter that counts the amount of active inputs [closed]

I want to make a direction guide using green, yellow and red LEDs. The lights need to change when ever the active input1 reaches a set value, for example: Green when the value is lower than 12; ...
1
vote
1answer
131 views

Osepp DS1307 RTC program error (tmElements_t tm; does not name a type)

Using a basic 1307 SetTime program, and ran into a problem (first time programming a module). #include <Wire.h> #include <Time.h> #include <DS1307RTC.h> const char *monthName[12] = ...
0
votes
1answer
68 views

Run function when triggered

I'm trying to create a motion/fall sensing device. I have a sensor that continuously checks if motion and fall is detected in void loop(). If both motion and fall are detected, then I'd like to send ...
0
votes
2answers
196 views

expected `}' at end of input

int scvVal = 6; int drvVal = 9; int sensorVal = A1; void setup() { Serial.begin(9600); pinMode(6, OUTPUT); pinMode(9, OUTPUT); } void loop(){ sensorVal = analogRead(A1); Serial....
1
vote
1answer
61 views

Seeburg Consolette Jukebox

I am working on a Seeburg Jukebox wall unit, I have it playing one track at a time form a SD card no problem. But what I need help with being new to programming is: 1. The code is long because it can ...
0
votes
0answers
44 views

empty message receive

#include <GSMSim.h> #include <SoftwareSerial.h> #define RX 7 #define TX 8 #define RESET 13 #define BAUD 9600 GSMSim gsm(RX, TX, RESET); const int doorSensor= 2; int doorSensorState= 0; ...
0
votes
1answer
56 views

can someone check my code, my Arduino isn't doing a consistent count cycle

Wondering if someone could have a look at my code and let me know if there's something wrong with it. I had the code done for me a while back and did a quick test and it seemed to work. I have now ...
2
votes
2answers
45 views

What Version of the Sketch did I leave on there?

Is there a way to "ask" the Arduino what sketch was compiled on it? There are several versions of the sketch and I need to see which version the Arduino has been running.
0
votes
1answer
52 views

Invoke a method in the main sketch from within a library

I need to use a specific library that issues error messages in the form of String texts. The library uses the Serial.println() function to send the messages to the Arduino IDE's serial monitor. The ...
0
votes
2answers
59 views

Interrupt triggering using DHT-11

I am new at arduino. I want to write a sketch that would print the message if the temperature grows greater than 30 C. Here is my sketch can you please tell me what's wrong with it #include "DHT.h" #...
0
votes
0answers
61 views

Cannot write pin LOW

All the other examples I've seen have had coding errors where they set a pin LOW in a loop with no delay so that it goes high again right away - but this problem is different, and probably something ...
0
votes
2answers
92 views

Prevent function inlining

I'm trying to shrink the compiled code size, and I have noticed that the compiler inlines functions a lot, even the ones I have not marked "inline", but I can't manage to turn that off. It looks like ...
0
votes
1answer
43 views

LCD displaying weird text

I am doing a project that requires input from a keypad to be displayed on the LCD display. lcd.print() displays in proper form, but when the I press characters on the keypad, they are overwritten as ...
0
votes
1answer
297 views

Multiple definitions of “xxxx” [duplicate]

I really need your help. I use VisualStudio and PlatformIo I still get this error: Linking .pioenvs\esp12e\firmware.elf .pioenvs\esp12e\src\main.cpp.o:(.data.DebugX+0x0): multiple definition of `...
0
votes
1answer
51 views

Any idea why my LED fails to operate with the if statement

I have tried several workarounds without success. #include <LiquidCrystal.h> float tempC; int tempPin = 0;// BS E D4 D5 D6 D7 int buzzer = 4; int LED =2; LiquidCrystal lcd(7, 8, 9, 10, 11, 12);...
0
votes
2answers
197 views

Esp8266 Vin pin

I've read that Vin pin is directly connected to usb cable in esp8266 (which is 5V). I wonder if I can power a relay 5V and a servo motor Sg90 with this pin? And is there any danger of doing that ?
1
vote
1answer
34 views

Create a device to detect object and voice alert what kind of object it is [closed]

Here is what I want to do (since I'm not a embedded guy) create a prototype with an Arduino to detect objects using camera(object classification?) that prototype will detect objects and alert that ...
1
vote
1answer
116 views

.elf and .hex equivalency? (code, eeprom, fuses, and lock bits all in one)

I have all configurations (eeprom data, fuses, lockbits) of my ATMega168A together with the code in my C files. The compilation creates an elf file that I use as an all-in-one programming file for ...
0
votes
0answers
106 views

Can I use an ST-Link to program an STM32F4 through the Arduino IDE?

I have a bunch of boards with STM32F's on them, and they only have JTAG headers. Is there some way to program and/or debug the boards
1
vote
1answer
62 views

How to execute operation once till a condition then restart it from start [closed]

I am making a project using IR sensor,servomotor and Push button. I am not able write code for the logic as stated: it will execute the operation when it reads the digital value of IR high and rotates ...
0
votes
1answer
33 views

Getting different values inside vs. outside a function while using global array

function splitter is designed to get a string of parameters and create a an array of parameters. If only part of parameters were given, the rest of them will get default values. for example : input ...
0
votes
2answers
389 views

How to combine two different sensor sketches to one complete sketch?

How to combine two different sensor sketches to one complete sketch for a complete circuit that attaches to one Arduino Uno? Sharp Dust Sensor int measurePin = A0; // Connect dust sensor to Arduino ...
1
vote
0answers
31 views

Help with app controlled Arduino sensors [closed]

(I'm a beginner in using Arduino and MIT App Inventor) We have this project (an app-controlled aquaponics system) where our group decided to use an app to control the arduino sensors and then show ...
1
vote
2answers
84 views

How do you make a switch case run until another serial input is detected?

I am trying to create a Traffic Light Controller. There are three modes to the controller: Mode 1 - the traffic light operates RED-YELLOW-GREEN-YELLOW and should repeat * (The other modes are not ...
0
votes
0answers
32 views

How to use parameteric function arguments

I have a function defined as follows: void turn_leds_on(int col_indx, int bright_1 = BRIGHTNESS, int del_1 = 5, bool dir_1 = true ) This function is called using MQTT from user to define led's ...
0
votes
1answer
102 views

Serial plotter isn't displaying my supplied data

I want to use serial plotter feature of Arduino by using DHT11 as humidity sensor at a time. But I'm getting problem as plotter is not loading by the code I have. Please help me what is the problem ...
0
votes
0answers
535 views

Can I use ESP8266 and OV7670 to video stream on a web?

OV7670 image sensor, small volume, low operating voltage, providing all functions of a single chip of VGA camera and image processor. so I am using and ESP8266 to connect to internet and stream the ...
0
votes
1answer
91 views

Parsing Data and Comparing two string in arduino

I am working on my final assignment. The problem is I want to make a prototype tool, with 2 string compare. If I send data "OK DISC DISCLOSED: 341513DB689AOK RSSI: -056 OK NAME: CarBT1 OK DISCE" will ...
1
vote
0answers
32 views

Troubleshooting Program using sensors and actuators

I am doing a project on waste management. I have to separate waste majorly as metal, plastic and other materials. For that using Arduino Mega 2560. I have connected Inductive proximity sensor @ A0 (...
-1
votes
3answers
79 views

Problem with a code

I have one problem with my code and I'm a beginner and I can't solve it. Can you help me? Thank you so much. I have this problem: error: expected unqualified-id before '{' token And this is my ...
0
votes
0answers
53 views

Serial communication problem NodeMCU

this is my first post here. Before I ask you my problem, I'm sorry if I'm wrong to write but my English is bad. So, my problem is this: I'm developing a "client-server" system with serial ...
0
votes
0answers
116 views

invalid pure specifier (only '= 0' is allowed) before 'int'

#include <PixySPI_SS.h> #include <Pixy.h> #include <Adafruit_MotorShield.h> #define X_CENTER ((PIXY_MAX_X-PIXY_MIN_X)/2) #define Y_CENTER ((PIXY_MAX_Y-PIXY_MIN_Y)...
1
vote
2answers
121 views

Creating an array of structures which store bitmaps to work with u8glib

I've tried reading the documentations and I'm getting desperate because I can't find anything. I need to create an array of structures, which contains a bitmap stored in PROGMEM space (because of ...
0
votes
0answers
40 views

how do i fill an array from a grayscale sensor (SKU:SEN0147)?

I'm designing a safe lock of 4 digits, but the password is in terms of colors, I have 3 colors. we are obliged to use a grayscale sensor (SKU: SEN0147). The assignment is as follows: Write a program ...
0
votes
2answers
223 views

How do I fill an empty array with the values from a sensor and compare it to another given array I filled before

I'm designing a safe lock of 4 digits, but the password is in terms of colors, I have 3 colors. we are obliged to use a grayscale sensor (SKU: SEN0147). The assignment is as follows: Write a program ...
0
votes
1answer
67 views

Arduino stops logging data after ~32761 seconds

I made a small set up to log temperature on SD card, everything is running smoothly until it reach 9:06:01 of logging that is 32761 seconds. I know that corresponds roughly to the maximum value of an ...
0
votes
1answer
52 views

When does a pre/post increment occur? [closed]

Editing here to clarify. The headline asks the question but the example given was not ideal. This was a more general Q than about the example code. Compilers have sequence points, places where you ...
0
votes
0answers
453 views

ESP8266 to send data to thingspeak while doing unblocked read on Serial.readString()

I have a requirement to get RFID data on Arduido UNO and send it to ESP8266 to be sent to ThingSpeak via the Wifi module. However, ESP8266 is also programmed to send Temperature and humidity data to ...
1
vote
1answer
208 views

Printing elements of char array from PROGMEM

Given: const char* PROGMEM names[] = {"Foo","Bar"}; Serial.print(names[0]); I get garbage output. Is there some function that will print the string from PROGMEM? E.G.: Serial.print(<function ...
3
votes
2answers
1k views

How to declare a global variable in the .h file?

I have a .h library file in which I want to declare a global variable that can be read in the program loop and in the library's .cpp file. The question is, is it possible to declare a variable in the ...