4

The quickest way possible from LightON to LightOFF is simply servo1.write(lightOFF); without loops or delays, in one go; no need to do it degree by degree. For example: int lightON = 180; int lightOFF = 90; for (pos1 = lightOFF; pos1 <= lightON; pos1++) { servo1.write(pos1); delay(15); } servo1.write(lightOFF); If you want it to move a few degrees ...


3

I see that MCP4725 uses Wire library with the default clock of 100,000 kb/sec. At a rough estimation each call to MCP.writeDAC or MCP.getValue will be at least 32 bits long and you use three of them in each loop. This one: Serial.println(MCP.getValue()); if (MCP.getValue()>threshold) is redundant, you should store the value in a temporary variable ...


3

If your goal is to "talk" to a computer vs. a human, then a format that can be parsed easily is better than one that is easy to read. For example, you have: I received: 255 I received: 247 I received: 11 I received: 0 While this could be parsed by your Uno, it will be a lot simpler if you send the data something like: 255|247|11|0 Now you can use ...


2

The best way is to use map() function. void loop() { unsigned long progress = millis() - startMillis; int angle = map(progress, 0, MOVING_PEDIOD, lightOFF , lightON); servo1.write(angle); } The above code use the millis() function, therefore you do not need to worry about blocking other code. Full instruction is available on How to control speed of ...


2

I usually recommend against using delay()s, but if this system will only ever have to do what you've described, using delay()s is the simplest way to implement it. I would suggest sending key-1, possibly several times, maybe a half second apart, delay for the 20 seconds you suggested, then send key-2, definitely several times for security.


2

If you want something simpler than the transistor version you can use the following as well, for the other options skip to the --here-- mark Oldstyle analog out. this works like a vacuum tube and while I use a LDR you can also use heat or a actual vacuum tube. You Will Need: A low resistance LDR or multiple in parallel. A cardboard box or other box to ...


2

Your slowness is because on every single iteration of loop() you are updating the entirety of the display. That's bad and wasteful. You need to do two things: Only display static information (the labels) once. Do that in setup(). Only display the variable data if it actually changes. The first is simple: move any static text to setup(). That means things ...


2

Your problem seems to be related to how you get the actual length you want to generate. There are other ways you could do that. Since your max seems to be 4 characters, you could possibly enter "9999" which would overflow the 50 bytes temp variable. You could simply read until \n and then atoi. Then cap at 50. As a side note, here's a function I've ...


1

You can manipulate the I/O ports directly from C++ without having to resort to assembly code. The AVR micro in your Arduino (ATmega328P) has three ports (PORTB, PORTC and PORTD) with eight pins each (Px0, Px1, ... Px7). You control the ports using three 8-bit registers. Each bit in a register represents one physical pin (LSB is pin 0, MSB pin 7): DDRx: data ...


1

ADC input has 100Mohm impedance. By placing C4 the signal at the ADC input has no DC path, is just floating between -0.7v and 5.7v , limited only by the input clamping diodes. ADC can convert only voltages between 0 and the voltage reference, I suppose you use the default 5V reference. But your signal is floating, and the ADC will cut any peaks outside of ...


1

This is actually a huge topic, one that I could write volumes on. However I will try and be concise. But it is such a common question it's time to finally write a definitive answer. Sending data between devices, be that computers, Arduinos, or anything else like that, is very much like speaking to someone. It is very common to do something like you have done ...


1

You did not specify the kind of Arduino you are using but, based on another recent question of yours, I will assume it is an AVR-based Arduino. You cannot have an interrupt automatically triggered by a variable reaching zero. What you can do, instead, is trigger an interrupt by software, by toggling a pin that is configured both as an output and as an ...


1

Simple if statements are very fast and won't affect performance much even when used in every looping of the loop. Using an interrupt to implement something simple like if (!amp) amp = 10; will probably make things slower: something will have to keep track of the counter to generate an interrupt, and this "something" takes MCU time, unless it is a ...


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