The process of improving the efficiency of a program such that is uses less memory and/or less computational time.
1
vote
1answer
34 views
Is setting clock divider worth changing on delay() to save power?
Along all the "advanced" methods described in this article, does simple method as downscaling processor while delay makes a difference on power consumption? How much time does the clock alternation ...
0
votes
2answers
42 views
code optimazation 6x6 Matrix
I planed a 6x6 matrix with a Arduino Nano as controller.
Its only possible to let one LED in the matrix lighten up.
Any idea how I get the Code smaller? (Im a C Noobie ^^)
~Nico
Circuit diagram:
...
1
vote
2answers
61 views
Low Power Library 4 seconds ON, 10 minutes OFF
Could someone please demonstrate how to use a counter with the Arduino 'low power' library to wait for 10 minutes then digitalWrite 4000, HIGH and loop. (I don't mean the simple 'blink' sketch).
I'm ...
-1
votes
2answers
51 views
3s on, 10minutes off low power
Can someone please demonstrate or point me in the direction for a simple example Arduino sketch with a digital pin output for 3s on HIGH and 10 minutes LOW, (in low power mode).
Thanks,
Nikian
0
votes
3answers
70 views
Arduino Blink two LEDs without Delay(amount of repetitions)
Arduino community. I have had experience with Arduino for 3 years now and have finally come to the conclusion to get rid of the delay function entirely.
Below is the code to blink two LEDs a ...
0
votes
2answers
20 views
Is this example for playing music without delay correct?
I've followed the directions from this answer, to try and play music without delay. This is my code so far:
#include "pitches.h"
int melody[] = {
NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, ...
1
vote
0answers
33 views
Optimization Teensy 3.6 Arduino IDE fast I/O Multiplexing Led Matirx
I'm currently working on a 10x10 LED Matrix which is controlled by 5 Shift registers using multiplexing. I've the problem that the Teensy 3.6 is too fast/slow.
One part of my code is the Shiftout ...
5
votes
2answers
144 views
How to increase life of EEPROM?
I want to store a few (8 as of now) IR codes into my Board's EEPROM.
It would be great if someone could suggest a few tips to maximize the lifetime.
The IR codes in my sketch are saved in array of ...
0
votes
1answer
73 views
FFT 8192 points with Arduino Due
I'm working with an Arduino DUE, trying to achieve a 8192 points FFT. I saw this post at Arduino Forum, but most of the links are broken.
http://forum.arduino.cc/index.php?topic=225204.30
I found ...
0
votes
1answer
145 views
Multiple if statements - stuck
I have a robot that uses two motors to skid steer. The robot gets input from three ultrasonic sensors (left, middle, and right) and a passive infrared sensor. If the robot detects a person in front of ...
-1
votes
1answer
75 views
Why is integer-to-string not working in this sketch?
I am using a Pro Mini to read analog values and to send them via serial.
Goal of the sketch is to stream these values to Serial as fast as possible, to obtain a steady stream of at least 1000 ...
0
votes
2answers
35 views
Arduino Mega prototype analog timer interrupts: newbie question
I am currently using an Arduino Mega with a fast vibration sensor to trigger the components operation (force sensor, temperature sensor) and also toggle sleep mode.
I am very new at this and I have ...
0
votes
3answers
17 views
Merging strings and constants causing scope errors
I'm getting a few errors when merging strings with constants.
Here's the pertinent code...
#define STATION_ID ABC123
#define STATION_PASS XYZ987
void loop(){
String path = "/weatherstation/...
2
votes
0answers
88 views
Faster output of Serial.print() data coming from TSL1402R sensor [closed]
I am reading a TSL1402R with an Arduino Mega2560. The code is based on the sketch from the arduino playground here:http://playground.arduino.cc/Main/TSL1402R
The application is a digital caliper for ...
3
votes
1answer
33 views
Read time digits from DS1307 and run code based on return
I am currently reading a DS1307 adafruit breakout board and I need to drive two nixie tubes from a shift register. The shift register is running two 74141 IC chips. I have code that loops through all ...
3
votes
1answer
99 views
PCF8547 Wire.write explanations
I am using an ESP8266-12E with a PCF8547.
I have managed to turn on and turn off LEDs using these two things.
I am using these three commands to do it.
Wire.begin(SDA_PIN,CLK_PIN);
Wire....
2
votes
1answer
67 views
Sim800L's library can not compile on Arduino Due
Sim800L's library can not compile on Arduino Due. Is there any way to create a library for Arduino Due?
#include <Sim800l.h>
#include <SoftwareSerial.h>
Sim800l Sim800l;
char* text;
char*...
0
votes
1answer
60 views
Is it possible to pass HIGH and LOW values as parameter in a function?
I've created the following function:
void runMotor(int _dir, int _step, int wait){
digitalWrite(_dir, HIGH);
for (int x = 0; x < 3200; x++) {
digitalWrite(_step, HIGH);
...
1
vote
1answer
46 views
Code Optimisation [closed]
I have tried fading the RGB Led with different colour format and sequence.
Working of Code :-
When value of number is 1, the Red LED fades gradually and glow up with the delay interval of 10ms with ...
2
votes
1answer
134 views
Results for GP2Y1010AU0F Dust Sensor
I am using Dust Sensor GP2Y1010AU0F
I downloaded the code from the manufacturer here:
http://www.waveshare.com/wiki/Dust_Sensor
/**********************************************************************...
1
vote
1answer
28 views
ble_write slows down my sketch causing problems (Blend Micro & NRF8001)
I'm working on a prototype which uses the RedBearLabs Blend Micro with the NSC's nrf8001 ble chip, but have ran into a problem that I'm not sure how to solve.
I have two tactile buttons connected to ...
1
vote
1answer
69 views
Help avoiding floating point math
I'm using a Texas Instruments DRV2605 haptic controller in my project to drive a LRA vibration motor. I would like to calculate the LRA rated voltage during run time using the formula below as ...
0
votes
3answers
605 views
How do I repeat a piece of code
For a school assignment I need to make a LED blink on/of 3 times then stop.
Now I have come up with the following code:
I think it's ''clean'' enough for what it has to do, but I have a feeling that ...
2
votes
3answers
207 views
A more elegant way to deal with timers without using delay()?
I am looking for a more elegant way to write a function that performs timer-based tasks as in the case of the code below, which essentially collects 5 sample values from a microphone module over a ...
0
votes
1answer
74 views
Faster and lighter approximate timing code without using timer
I want to use loop() iterations counter to execute some tasks periodically or tasks like debouncing. My other sketch is running every loop() at least 20 ms, and if i am using 5 ms time to wait to
...
3
votes
1answer
392 views
OOP vs procedural programming on arduino
It seems like the majority of Arduino applications are written without using classes / objects. Is there a reason for this? Does is slow down the Arduino or somehow present undesirable behavior?
4
votes
3answers
231 views
Set EEPROM from PC before program
I have been working on an arduino program, which has gotten rather large. I am close to hitting the 32k limit on Flash for my ATmega328p. I would like lower my program size by saving some of my many ...
3
votes
2answers
118 views
What is the proper way to implement PID?
I'm having some trouble conceptualizing how to go about implementing PID into my drone. There are a few ways I'm thinking about implementing the pipeline:
Having one PID Object for each of the six ...
1
vote
3answers
549 views
Storing an array of function pointers
I have some Arduino code that looks like:
char packet = ser.read();
switch(packet){
case 'a':
someobj.somefunc();
break;
case 'b':
otherobj.otherfunc();
...
0
votes
2answers
46 views
Interrupt numbering
I'm using an Arduino Mega and four of its interrupts. Each interrupt is only used to start/stop a timer, depending if it's rising or falling, so effectively runs the same function. Does anyone know if ...
0
votes
4answers
58 views
Refactor to save bytes?
I'm a painful 128 bytes of my max for this Trinket. Any refactoring I could do to get down the size?
#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include <RTClib.h>
#define ...
2
votes
2answers
84 views
Possible to condense this if statement?
I have this if statement:
if (now.hour() == 5 && now.minute() == 10 && now.second() == 0 && now.dayOfTheWeek() != 1 && now.dayOfTheWeek() != 7){
Is there a way to ...
0
votes
1answer
49 views
How would I refactor this code, given how similar most of the lines are?
I have a set of buttons and a set of NeoPixel LEDs. There's lots of very similar constants (button1pin, button2pin, etc) so there's almost certainly a more efficient way of coding this.
Any ideas?
#...
0
votes
4answers
94 views
Can I short this code?
int r = 12;
int g = 11;
int b = 10;
int sw = 4;
int x;
int c = 0;
void setup() {
pinMode(r, OUTPUT);
pinMode(g, OUTPUT);
pinMode(b, OUTPUT);
pinMode(sw, INPUT);
pinMode(13, OUTPUT)...
0
votes
2answers
599 views
Convert uint8_t array to ascii character for serial transmission
I am trying to send packets of via bluetooth data that include 6 bytes read from a sensor and stored in a uint8_t array. Instead of sending over the data as numerical digital, I would like to send the ...
1
vote
2answers
54 views
Port Manipulation - fastest implementation
I'm working on an Arduino program but am getting bogged down on what is the 'correct' implementation. I understand that multiple versions may work, so for my needs the 'correct' version will be the ...
-3
votes
1answer
112 views
How do I learn C? (was Computer project) [closed]
Can you help me writing a code for this question guys??
You have an Arduino Uno with 8 LEDs connected to digital pins 2 to 9.
Create an array of 8 elements. Fill it with random numbers between 2 and 9 ...
1
vote
2answers
62 views
Digital Vs. Analog Sensor
Background: I'm using an Atmega1284P to add sensors to an off road racing truck onto a CANBUS network. The standard automotive sensors are thermistors, but the Dallas 1 wire temp sensors (DS18B20) ...
4
votes
2answers
112 views
Problem with inaccurate delays between sensor readings
During the last two months I have been working on a project that consists of using a Seeeduino Stalker V2.3, two AM2305 sensors, a TSL2561 sensor, an HC-05 XBee module, a 1,800 mAh 3.7V LiPo, a 7 cm x ...
0
votes
2answers
80 views
How to prevent inclusion of unnecessary libraries?
How do you save space by preventing the inclusion of unnecessary binaries?
When I compiled the ROS Blink example, I received the warning:
Global variables use 1,951 bytes (76%) of dynamic memory,
...
2
votes
4answers
3k views
What is better: one sprintf() or multiple strcat() and itoa()?
I was creating Arduino function which sends two int and additional chars between them and at the beginning and end of char array - then print that array to the serial port in almost real time. (For ...
1
vote
1answer
341 views
Arduino Due SPI speed reduction
I need to reduce the SPI clock speed of the Arduino Due down to about 100 kHz. Unfortunately my hardware doesn't support higher speeds.
With the current maximum divider of 255, I can only reach a ...
1
vote
0answers
36 views
Phone-Arduino system [closed]
Is there any application or program that can allow a user to change particular parts of a code? The user types in some defined "instruction" into their smartphone and it changes say the intensity of ...
2
votes
2answers
126 views
How do I set a constant in setup() that I can use in loop()?
I am new with coding, and I was wondering how I could run something once and define it as a constant. Here is my code:
int sensorValue1 = analogRead(A0);
int sensorValue2 = analogRead(A1);
int g0 ...
0
votes
3answers
265 views
Arduino: how can I stop while() when bluetooth send a data?
I have learned Arduino for a month, and I want to bulid a car with 2 modes,
Remote and Auto. Auto mode needs to have while() loop, so it can receive data from sensors. When I choose Auto mode via ...
0
votes
1answer
434 views
Using for loop to set pinMode
I notice problems with my output pins when I use this method of setting their pinMode:
int allOutputPins[] = {3, 4, 9, 10, 5, A3, 11, 12, 7, 8, A1, A2};
for(int a = 0; a < sizeof(allOutputPins); ...
0
votes
3answers
111 views
How to store IR data needed for AC controll in less space?
I'm trying to controll an AC unit but the issue is space - right now, I store the data like this:
consts PROGMEM unsigned int Signal_Heat_Fan0_Temp30[] = {233,636,17884,3032,8944,500,496,492,1496,524,...
1
vote
3answers
129 views
Are static variables in a function bad?
For my code I use a couple of static variables.
But when I search the internet, they seem "evil".
For example: I have a function which will be executed every loop (5ms looptime).
to increase the ...
-1
votes
2answers
465 views
SD Library writing char in a file
I'm trying to write into a file using this code from the example of the library:
String dataString = "";
int sensor = 0;
dataString += String(sensor);
dataString += ",";
sensor +=1;
File dataFile = ...
0
votes
3answers
65 views
Simple question about && vs ||
I want to skip all '\r' and '\n' chars and I have IF statment:
char c = Serial.read();
if (c != '\r' || c != '\n') { // <- This line interesting
mAnswer[mAnswerLength] = c;
mAnswerLength++;
...