#help-with-arduino
1 messages · Page 45 of 1
no
you can probably scroll the black window at the bottom
exit status 1
Error compiling for board Arduino/Genuino Uno.
that's all i see
hmm ok lemme see
Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Uno"
In file included from C:\Users\Tarun\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.cpp:15:0:
C:\Users\Tarun\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.h:36:29: fatal error: Adafruit_Sensor.h: No such file or directory
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
this is the entire error message
@pine bramble Try turning on verbose output.
ok there we go, you probably need the unified adafruit sensor library installed
install it the same way you installed the dht lib
verbose output means more detailed error messages
I think you just need to install the adafruit sensor library
i did
Yep, you likely need to install Adafruit Unified Sensor library. Try that.
hmm ok lemme see
Sketch > Include Library > Manage Libraries…
then search for Adafruit Unified Sensor
It may be at the bottom of the scrolling list.
That's in the guide section I pointed you at earlier. 🙂
But it can be easy to miss a step.
i did it now it says : 'DHT' does not name a type
Are you trying the DHTtester example?
no
I would suggest working through that section of the product guide completely, which includes the DHTtester code.
That will ensure you have everything set up.
Is it possible to use an existing C library within the Arduino IDE?
- The library comprises '.h' and a '.cpp' files.
- The library does not already exist under existing 'manage libraries' option in the IDE ( I download it from github).
- When using the 'include zip' option (https://www.arduino.cc/en/guide/Libraries#toc4) then I get an error -
https://downloads.arduino.cc/libraries/library_index.json.sig file signature verification failed. File ignored.
All thoughts welcomed.
For info - library location is: https://github.com/pavelmc/Si5351mcu
Thanks
You can make it into an Arduino library, but it's generally easier to just put the .c and .h files in the same directory as your .ino file.
Thanks for that. I will give it a spin!
Update - I have the library files copied into the same directory as the '.ino'.
However I am still getting the file signature verification error.
I do not know if this is fatal or just for info.
Assuming the former, is there a fix?
Thanks
What are you doing when you get the signature error?
Merely editing the '.ino'.
The processor board is not connected at this stage.
I had no idea the code editor had a signature check. I was guessing you were getting that error from the compiler or library manager or something.
OK. I saved the '.ino' and restarted the IDE.
No error at this stage, even when I edit again, so no idea why that popped up.
I guess the proof of the pudding will be when I attach the board and try to compile.
I did notice that now I have three tabs showing as below.
I remain unclear how my code accesses the '.cpp' - do I need another 'include' for that?
The linker will include the .cpp file with the .ino file, you will need to #include the .h file in your .ino
Done deal.
Thank you again.
@signal plaza Your .ino may be empty (entirely). If you do so, each .cpp file must have a header:
#include <Arduino.h>
The one directory name automatically recognized, is
./src
It will find all .cpp files anywhere under ./src within reason (may not look in ./src/.directory for example).
Only one .ino per project, though.
Nick Gammon
Pre-processor problems
October 2014:
https://www.gammon.com.au/forum/?id=12625
Ah, that's good to know. I'd had issues with typedefs in the past, and just dispensed with them instead of investigating.
I never did prove that ./src was the only allowed directory name, one level down from the project level.
I tried it experimentally on a hunch. It worked. Nothing else did.
I kind of held the Arduino IDE and overall system in disdain, until I worked with Atmel Start (sort-of 'bare metal' or maybe just 'manufacturer's libraries/methods, only').
For the curious, here's the main that the Arduino code uses: ```c
int main(void)
{
init();
initVariant();
#if defined(USBCON)
USBDevice.attach();
#endif
setup();
for (;;) {
loop();
if (serialEventRun) serialEventRun();
}
return 0;
}
Nice syntax on that for loop ;)
@pine bramble I think I’m going to start pronouncing that pattern for 😉😉
/path/.arduino15/packages/adafruit/hardware/samd/1.5.7/cores/arduino/main.cpp
for (; ;)
Default initializer (no-op), default test (true), default incrementer (no-op)
I think O was trying to say they look like smilies emoticons.
When people do all those =D things I just ignore them as untranslated emoticon.
O_o
See I have no idea what that'd mean. 'bubble memory' comes to mind. ;)
I borrowed this one from a MOO I think:
.oO( .. thought balloon)
Is it possible to have multiple callbacks in the same program? Like if I had one callback running some audio playback and another incrementing variables and stuff like that?
I'm on a PyGamer using Arcada
I'm making a wav player
I use one for playing the wav files
void wavOutCallback() {
wavStatus status = arcada.WavPlayNextSample();
if (status == WAV_EOF) {
arcada.timerStop();
arcada.enableSpeaker(false);
playing = false;
} else {
playing = true;
}
}
And the other times the wav file being played
void wavTimeCallback() {
if (playing && !paused) {
wav_time = millis() - wav_start_time;
}
}
I set up both with arcada.timerCallback(speed, pointerToFunction);
I would expect the last one to overwrite the first
@rough torrent I'd try it, and see if it works. I think it should, as long as variables like playing, paused, wav_time, etc. are declared with the volatile keyword, and you're careful to do as little work as possible inside the ISRs (callback functions).
Basically any global variable you're changing inside an ISR callback needs to be declared volatile.
Also, you need to register each callback separately.
It does replace the timer callback
Those are small enough to gave in the same callback function though on pygamer
I need some help with an arduino code.
I am using a barcode scanner from which I want to save the code into a variable and print it
Right now the numbers are chopped somehow
while(barCodeSerial.available()){
delay(1);
code += (char)barCodeSerial.read();
}
Serial.println(code);
code = "";
}```
This is my loop
@wind drift It may be that while the reader is sending you as much as it has at a given time, there are some tiny pauses, and your code thinks that's the end of that segment.
Well if I remove my delay I get single digits
Does reader send a special character at the end of a barcode, like maybe ASCII 13?
I don't see any - or is it an invisible character?
Can you point to an link to the barcode reader you're using?
oof not sure - I only got a chinese doc with it
mostly chinese- a little bit of english in there
In absence of a special character, I'd go with a timeout strategy. Can you point at the Chinese doc?
Is there an Arduino library it uses?
Sweet
Okay I found a sort-of-temporary fix - I increased my delay from 1 to 5 ...
But I can imagine it will give me some problems lateron with false readings or something.
I am open to better ideas 😄
If there's no special character, than I'd do a timeout approach, and a state machine.
- create a global variable
uint32_t lastReadTime, andbool inString = false, and set the first tomillis()insetup() - each time a character comes in, reset
lastReadTimetomillis(), and setinString = true - in the loop if there's no character available to read, set
uint32_t curReadTime = millis();
** if inString == true, and if curReadTime - lastReadTime > 250, we've waited long enough. Output the string, and reset inString to false. And erase our buffer.
Basically, keep reading characters and appending them, but if 250ms passes and nothings coming in, we dump what we have. Could be 100ms, or even smaller.
does anyone know how can I generate a .hex file to upload using software such as Xloader?
Awesome, @wind drift ! You interpreted my rough rambling into real working code!
Try a really small threshold, like 50 ms! That may be enough, and would be super fast. On the other hand, if it's too small, you'll see the issue you had earlier. So it's a tradeoff between lag time (currently 1/4 second) and reliability.
@fallow wind The .hex and .bin files are in the same directory.
oh? I usually just sketch and upload, thanks @pine bramble !
Heh, you're welcome. I haven't figured out how to use the .hex files. There's two of them for each build (one has a bootloader, judging by the name it gets).
@fallow wind @pine bramble There are a couple methods in the answers here:
https://arduino.stackexchange.com/questions/48431/how-to-get-the-firmware-hex-file-from-a-ino-file-containing-the-code
I did not know about either of these!
There's also the .elf file which I think is used with objdump and the source code tree.
thank u both, I'm getting the hex file and I'll let u know tomorrow when I upload it
I've also compiled and installed onto Adafruit Express boards, then grabbed the .uf2 off the virtual drive the Express devices mount in the file system. I (or customer/client) can drag this to a mounted device, as long as it's identical.
No Xloader needed in that case!
I'm just looking to upload a custom grbl to a nano which has another custom grbl without bootloader (I think that's the thing requited to upload new sketches into the arduino)
thx for the help!
Here's objdump in action:
https://termbin.com/hud3q
Ahoy there! I’m trying to get this TFT display to work. Does anyone know what can cause this bug?
This was the expected result of the test program:
I'm using a Wemos D1 Mini and the DL144128TF 1.44" X 1.44" 128X128px TFT display described in this wiki post: https://www.elecrow.com/wiki/index.php?title=1.44''_128x_128_TFT_LCD_with_SPI_Interface
Nevermind, found the answer here:
Does someone have an easy example for switching a neopixel led color to a differnt color by pressing a button?
neopixel on the nrf52480 feather express
okay now I am even more confused than before. Somehow the BLE example code is not working anymore. It's no longer showing in the list and there is no blue LED. I tested it on 2 nrf52480 feather express boards
Ok nevermind got the ble working again. Forgot to open the terminal
But still not sure how I can control the neopixel on the board ...
Or is that not possible?
@wind drift The on-board NeoPixel pin is PIN_NEOPIXEL according the pinouts section of the primary guide for your Feather:
https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather/pinouts#rgb-neopixel-3-17
Ohh I see let me try that
@north kelp I worked around a bit more with my barcode scanner. I noticed that I can apparently get a special character
See the questionmarks
but how can I 'detect' it?
I tried different baud rates but they all show the questionmark
I can get a -1 if I don't add the (char)
Possibly an "end of code" symbol, or your read routine returning a -1 because there's no more data available?
@wind drift I'd try casting the character to a number; this (untested) code should give you the raw ASCII character number: ```cpp
Serial.println((uint16_t)barCodeSerial.read());
Oh wait; maybe what you're doing already does that?
Anyway, I'm guessing that the end-of-barcode byte may be -1 (signed) or 255 (cast to unsigned). Testing for this could be easier and faster than doing a timeout. Doing both (“suspenders & belt”) would ensure the system could recover if there's some odd transmission glitch.
Okay got another question.
I want to have a timer counting down from 5 to 0 and then print something. But I am abit confused about the millis function. How would I do it there? I only got it to work with delay
The timer should start after I press a button
#define SECONDS(x) (1000 * x)
#define UPDATERATE SECONDS(1) // update this often
#define COUNTDOWN SECONDS(5) // count down from this much
unsigned long curtime;
unsigned long next;
unsigned long timetogo = 0;
void loop() {
curtime = millis();
if (digitalRead(switchpin) == 1) {
// set countdown time
timetogo = curtime + COUNTDOWN;
next = curtime + UPDATERATE;
}
if ((timetogo != 0) and (curtime > next)) {
// time for an update
if ((timetogo - curtime) > 0) {
// still going, print current value
Serial.print((timetogo - curtime) / 1000);
next = curtime + UPDATERATE;
} else {
// done
Serial.print("Done!");
timetogo = 0;
}
}
A little sloppy, but that's one way you could do it.
I skipped over some stuff like configuring the switch pin and setting it as an input, etc. but I think I hit the basics of starting a timer, emitting its value at regular intervals, and stopping when it's done. Another approach would be to just use next with millis() and simply count seconds with timetogo, which could avoid roundoff error and and the need to zero it when the timer runs out, but if the CPU gets distracted for significant time, could lead to lost seconds.
Can't get it to work how? Does it compile?
Okay I tried a normal counter with millis (1000)
I noticed the timing is a bit off?
{
boolean newState = digitalRead(BUTTON_PIN);
if((newState == LOW) && (oldState == HIGH)) {
delay(20);
if(newState == LOW) {
counter = 5;
startMillis = millis();
while (counter >=0 ){
currentMillis = millis();
if (currentMillis-startMillis == 1000){
counter = counter-1;
Serial.println(counter);
startMillis = currentMillis;
}
}
}
}
oldState = newState;
// Serial.println("not counting");
}```
I just tried this one
it is sort of counting down
but it prints it all at once
so I press the button - then nothing happens - after 5 seconds it prints the 5 numbers all at once
And why is it printing the -1
you're decrementing the counter before printing it in a loop which allows it to be >= 0. When it's 0, it enters the loop, you decrement it, then print it --> -1
Ah right
Any ideas about the print delay?
I am guessing the while loop is the problem
Could be that it's not exiting loop(). The code has changed a good bit
Well basically I am checking if the button is pressed then set counter to 5.
Check current time and set as startmillis.
Then as long as the counter is >=1 check the current time and set as currentMillis
if currentMills-StartMillis == 1 second set the counter -1 and print it
And set the new startmillis to currentMillis
From my thinking it should print them 1 by 1 every second
void loop()
{
unsigned long curtime = millis();
boolean newState = digitalRead(BUTTON_PIN);
if ((newState != oldState) && newState == LOW) {
counter = 5;
next = curtime + 1000;
}
if ((next != 0) && (curtime > next)) {
--counter;
Serial.println(counter);
if (counter == 0) {
next = 0;
} else {
next = curtime + 1000;
}
}
oldState = newState;
}
I assume int next?
Hm it does not seem to work
ah kinda got it
ah got it now - forgot the counter=5
perfect - thanks!
Looks good
@north stream I have one more related question. I am trying to measure an object on a scale. Usually they 'save' the measured value after 3 seconds, when the weight is stable
How would I do that?
I notice that my scale is putting out different values everytime (.x grams)
So I guess I have to make a range x > value < y
But not sure how to combine it with the timer
I might do something like set "last out of range" time to millis() when the "in range" check fails, and when it succeeds, compare the "last out of range" time with the current time: if the difference is more than the settling time, accept the value.
Soo I would put it in a while loop?
I think this is the best place for my question. Working on an Arduino Uno shield, trying to solder some wire onto the end of an already soldered pin. I have solid core wire - would this be easier with stranded? I’m having a really hard time getting things together. Sorry for the potato quality picture, but you can see the pins I need to solder these wires to.
Stranded wire is mostly for when you need it to flex all the time, like a headphone's wires (or a 120 volt power tool, for example).
Solid is better in every other way, and is usually easier to work with for soldering.
Best bet: experiment; your soldering technique will prefer the one or the other.
(You can sometimes cheat and use only half the strands, for example, to fit a smaller area, so stranded in that case works better).
Okay, maybe I’ll keep tinkering with the solid core before I spend money on stranded. Thanks!
Sucks that I couldn’t use more of the breadboard style connections lol
You can use header pins and save a lot of trouble.
The 'Assembly' instructions for many Adafruit products shows an easy way to secure them, using a spare breadboard as a holding jig, during soldering.
If your protoboard has 'busses' (several holes connected together by copper foil) you don't have to worry about multiple connections to a single header pin.
They’re actually the other side of a set of header pins! This shield is going to be an easy-use ISP programmer shield, so I have (female) header pins to house the board to program (a digispark) and am running wires from the GPIO pins to the bottom-end of the headers.
Now that you’re mentioning it, however, extra long headers would have made this easier
Yeah sometimes you can cheat with extra long headers and jumpers underneath.
Other times soldering is the only game in town.
Hello all I'm new to this please bare with me not a tech savvy person, I just purchased tv be gone, I'm working on a project to code it. Have you ever heard of IRJ4?
Possible that no one can help me ? :(
i am having hard time in figuring out what arduino code would allow me to use 2 accelerometers to control the rotation of one servomotor.
The idea is to wear the 2 accelerometers on the feet, 1 accelerometer per foot and based on how fast or slow i step in place, the rotation of the servo motor changes and stays at 2 specific angles .
Let's say 90 degree is the angle of the servo associated to no movement of the accelerometers.
110 degree is the angle of the servo associated to the stepping/walking in place at a costant low frequency of movement of the feet/accelerometers
130 degree is the angle of the servo associated to the stepping/walking in place at a costant higher frequency of movement of the feet/accelerometers
Any help please ?
I outlined a solution before, and you said you didn't understand it, I'm not sure what to do.
I guess you could check the accelerometers values and see how they change over a certain period of time
Similar to a stepcounter
@north stream , i have no idea how to put your idea in arduing coding lines
"I'd probably have something like "note the timestamp when the acceleration goes through zero in a positive direction", "note the timestamp when the acceleration goes through zero in a negative direction", subtract the timestamps to get the elapsed time, then if it's small (more frequent motions) set the servo to a bigger angle, if it's large (less frequent motions), set the servo to a larger angle. Probably need to fold in logic to look for reasonable sized peaks in-between, to avoid spurious crossings, and to cross-check the two accelerometers for alternate motion."
Something like: ```c
#define FASTPERIOD 200
static bool foot1pos; // foot 1 currently positive acceleration
static bool foot2pos; // foot 2 currently positive acceleration
static unsigned long last1; // last time foot 1 went to positive acceleration
static unsigned long last2; // last time foot 2 went to positive acceleration
void loop()
{
unsigned long curtime = millis(); // current time
unsigned long period; // time between steps
if (readaccel(foot1) > 0) {
if (!foot1pos) {
// foot 1 going positive
period = curtime - last1;
if (period > FASTPERIOD) {
// long period means slow gait, set slow angle
setservo(slowangle);
} else {
// short period means fast gait, set fast angle
setservo(fastangle);
}
// remember parameters
last1 = curtime;
foot1pos = true;
}
} else {
if (foot1pos) {
// foot 1 going negative
foot1pos = false;
}
}
}```
I have this very weird problem with Arduino pro mini: it cannot be programmed. Not with serial, not with ICSP. I know it works beause it runs a default blink sketch, but other than that I can't do anything with it
Thank you @north stream for the coding! My current coding looks like this :
I am not sure how to paste the code in here like you did
based on my code above, how can your code be adapted
?
I undertand the code I shared with you, but I can't figure out how to define the values for the code you shared.
I am so ignorant on this
I'm in the middle of a little home disaster, and don't have the bandwidth to do a code merge right now, unfortunately.
sorry 😦
No worries, just explaining why I'm not able to help that much at the moment.
Thanks. I hope things get bettet for you
I'm dealing with it, but it was an unwanted surprise and a lot of time and effort I hadn't planned on.
@potent ferry , why do you need to do that hard thing, you can use some switches/buttons and then in your code you can count how fast they are pressed (while you walking) and based on this speed turn your servo!
Hi @velvet charm are u suggesting to use pressure sensors instead of accelerometers ?
This is my project
I use pressure sensors for backward movements and lateral movements. The problem that i would imagine facing if using pressure sensors for walking accross a room or/and walking in place and/or running in place might be
-
what happens when i lift the foot a little to reach the pressure sensors that i mounted in the inner part of my shoe and also the pressure sensors that i mounted on the back of my shoes?
-
are there affordable pressure sensors that would support that intense pressing of body weight for walking and running over them?
What do you think about the 2 points above, keepimg in mind the whole setup i weote in the sketches?
This video is of the pressue sensors for lateral movements
This is for the forward movement and for the backward movements i use 2 pressure sensors , similar as i use rhem for lateral movements . In this video i go backwards just because i mounted the motors the opposite way. That was an easy fix. I move forward in games with accelerometers but the way my code is setup , does not work well when passing from slow walk to run and the opposite
Because my arduino code is set up on accelerometer angles and not on accelerometer frequency
lso in this last vidoe, this is running the old version of the code. Now the code is a little different
@potent ferry , yes, it is easier to code
but how do you handle the fact that I am lifting the feet for also pressing sensors for lateral movements and backward movements
?
how can I then use the pressure sensors to walk and run ?
what pressure sensor can handle my weight and gravity of stepping hard when running on it ?
Ok, my idea isn’t very good
no no, maybe you have a solution for that
This is how I would move in a game:
https://www.youtube.com/watch?v=7K5CsQb0-ZI
This is achieved with sensors though and a 3rd part software, not with arduino. The goal to achieve, is exact the same though. Look at my feet
"Days Gone" on Oculus Quest through Virtual Desktop, using cinemizer headtracking ble modified for headtracking/head movements and DIY shoes for locomotion b...
This method on this video though has limitations due to software, so to differentiate walk and run, i need to push a button to activate and deactivate a code. That is due to software limitations that I can bypass instaed through the arduino method I am working on
I want to investigate more your suggestion. I am not dumping it
Anyone, i have a question about accelerometers and arduino.
Would it be possible to connect 4 accelerometers to 1 arduino, to control 1 servomotor ?
Right now i have 2 accelerometers connected to 1 arduino, to control 1 servomotor.
@potent ferry Assuming they are I2C devices then they must have unique addresses. Which accelerometer are you using? If you cant set 4 different addresses, you should be able to use an I2C multiplexer like this one: https://www.adafruit.com/product/2717
or do it in software with my multi_i2c library
most accelerometers have 3 address lines exposed, so you could have up to 8 unique addresses
hello, i have a question.
can esp32 use ble(scan) while deep sleep?
(i want esp32 to wake up when esp32 scan ble_server)
the BT radio is directly driven by the ESP32 CPU, so that doesn't sound possible
Does the feather count as arduino?
@late shoal are you programming it from the arduino application?
Has anyone had trouble uploading code from Arduino to a Circuitplayground Classic? I’m getting the same error. Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding avrdude: ser_recv(): read error: Device not configured. I’m using a good usb cable. I’m able to upload to my other boards. I’ve updated my boards and libraries. I’m on a Mac 10.15.1. Arduino version 1.8.10
Hmm, I don't remember what programmer the Circuit Playground Classic uses, but I don't think it's the butterfly. What do you have the board and programmer set to?
So I’ve powered neopixels off feathers before by putting the BAT pin to the +5v on the neopixel to avoid the 3.3v regulator. I’m looking at the schematic layout and it says BAT is just a connection running to the positive battery terminal. What’s the current limit on the trace? What if I want to draw 2amps on neopixels. How could I safely draw battery power off a 6600 maH pack. Clearly the battery is fine, but im concerned the trace isn’t designed for that. Should I splice in a larger gauge wire between the jst connector and the battery on the positive wire?
power the LEDs from a separate supply and link the grounds together from the 2 different sources of power
@north stream I was trying some Neopixel code, but now I’m just using the basic blink sketch included in the Circuitplayground Arduino example. So, the code isn’t an issue. The programmer is set to USBtinyISP. I didn’t think that setting affected programing this board.
Bitbank, but using the on board battery charger would be very nice
you can drive LED strips with low current if you set them to minimum brightness 🙂
the voltage regulators on development boards usually expect to supply in the 150-300mA range. Some of the newer Arduinos can supply up to 1.2A
for long LED strips you need a dedicated high current supply
Well that’s why I’m hooking to the BAT pin to bypass the voltage regulator 🙂
Oh - I think I get what you're saying.
I guess it depends on how many LEDs you're going to drive and how bright
The battery voltage may sag a bit due to the current driving the LEDs and the trace may not support too much current
You could run separate leads from the battery to the Feather and the LEDs, then you could use the on-board battery charger and not worry about overloading the traces on the board with LED current. It's a little external wiring, but should do what you want.
That’s exactly what I was thinking after sleeping on it. Wasn’t sure it was “legal” or I was missing something that would cause the battery to go kaboom 🙂 I hate getting lithium ions in my eyes 🙂
It's just moving from routing current through a trace on the board to routing current through a wire, the real difference being that the wire can carry more current safely.
I often find I'll come up with a better idea when I come back to a problem with fresh eyes.
One other thing. I know neopixels can pull 60mA at full white at full power. Is that a 5v statement?
If I’m powering them with 3.7v battery, is the current draw the same even though they can’t get as bright at “full power” due to the lower voltage? Just trying to size my batteries and wires correctly
They'll get essentially as bright even at 3.7V, so you should still plan for 60mA per pixel (80mA for RGBW pixels).
Hi @odd fjord . I am using two Gy-521 MPU-6050 but i also have two ADXL345
Hi @acoustic nebula , I am using two Gy-521 MPU-6050 but i also have two ADXL345.
The two mpu-6050 i am using, are running in my arduino code as separate accelermoters with y1 and y2 values output when i move them and rotaring the same servomotor.
How can i connect on an arduino uno the other 2 accelerometers so that they output y3 and y4 and they can control the same 1 servomotor tb3at the other 2 accelerometers control ?
The accelerometer doesn't control the servo, the Arduino controls the servo. You just need to decide what effect you want the additional inputs have on the behavior of the servo.
You can set unique addresses to each
the little dev boards usually expose at least 1 address select line
let me double check mine...
Yes, the GY-521 exposes the AD0 line. Tie it high for one address and low for the other
I don't have any ADXL345's handy, but I think they have the same kind of arrangement
I would use the 4 accelerometers the same way i am using 2. Pratically 2 woukd control the walking and 2 the running. Meaning 2 acceelrometers would rotate the servo of a low angle and the other 2 would rotate the same servo toward a bigger angle.
Lets say angle 90 degree is the servo at its center. 2 accelerometers would control the rotation from 90 degree to 78 degree, and the other 2 accelerometers would control the rotation of the same servo from 90 degree to 70 degree or from 78 degree to 70.
The old code on the CircuitPlayground still runs. I’ve been working at it and hit the buttons. They still light up the neopixels in a pattern.
Doh one last thing, I’ve always added a beefy capacitor across the + to - for when I power neopixels off a wall power supply. Is it necessary for a big capacitor if powering via a battery?
The capacitor will be helpful there too.
@acoustic nebula
This is how i am wirimg on the arduino, 2 accelerometers and 1 servo. What the other 2 accelerometers should use?
GY6050 gyro1(0x68);
GY6050 gyro2(0x69);
I can't see from your photo, but I2C is a bus; all devices share the same SDA/SCL lines
or you can use my Multi_BitBang library to talk to I2C devices on any GPIO pins and have multiple devices with the same address
Good Morning/afternoon folks. I have a noob question. Int is a global integer, so does this mean that #define is specific to a library?
int can be either global or local, depending on where you declare it
Ok. So when a prhase has #, does it mean it’s function is defined in a library?
If it has a #, it means it is a preprocessor instruction, most likely a macro
or a constant
🙂
good to see you again sir 🙂
Yeah, you too.
My memory is terrible and I don't use avatars here so I have to remember people on a rather sketchy basis.
Oh you're the one who said 'I'm an old'
im the guy making a space station pointer, and you seemed to be a space nerd too. i mentioned using celestrak for my TLE data and asked if there was a better source, and you said it was the best place to be
yea, im also an old lol
I've been repeating that one all week
🙂
Not an old man. An old. I think that's uproariously funny.
I appreciate the recap, it helps a lot!
Yeah I thought you were a Brit but then you said stuff that made that less likely.
nope. im in california, about 1hr east of san francisco. just far enuf to keep the hippies at bay
there is a large hill/pass between us. the super crazy ones tend to stay on that side
I'm about an hour from the ocean.
im still a california hippie, but not nearly as crazy as those other folks lol
which ocean?
Culture is weird in what it spreads and how it spreads it. I'm in CT so the ocean is the Atlantic.
gotcha
I have not visited the Pacific Ocean.
Went to Yurrup in like 1977 or so. Canada near the border with the USA in the East.
farthest east ive gone is the iowa illinois border, saw the mississippi river
davenport ia i think?
I've probably been to about 35 states and lived in Colorado, twice.
i travelled around climbing radio towers for a few years. spent around 6months in omaha, NE. a few months around iowa + illinois. never got to see chicago tho
then we headed back and stayed in dallas, tx for a while
lots of good stories, but im glad im done with towers lol
I'm going to go out and do that thing you do and then come back inside the house. ;)
not a bad idea, think ill join ya. see you in 8mins or so
(they got the hidden meaning!) spy vs spy
so... ive got a 2x16 char display, and i want to show 16 lines of data on it. the plan is to show + update 2 lines of info for 5seconds, then switch to 2 diff lines of info and keep it updated for 5secs. so a state machine
next, cram the info into 1x16...
identifier text will be stored in code, example time/date is Tm: /Dt:
my space tracking functions return between 0.000 and 359.999. so i need to intelligently cut off some decimal points. im more comfy with printf than i am with cout, but im open to using either. gunna start with printf since its more familiar
the sprintf and snprintf functions want to add a 0 terminator to the end of the string, and im pretty sure my 2x16 display wont like it. so either i chop it off before it gets sent... or i use sprintf() on each value, and use strcat to add it to a char[] manually
Az: 200 El: 134
When I first read that, I was imagining using the display as a 16-row bar chart, which might be possible, even though I later realized that was not what you were describing.
Most of the display libraries accept a simple null-terminated string, so sprintf() may be the way to go.
but no i just want text
lets try again...
AZ: 359 EL: 180
thats 16. no decimals. i may want decimals
AZ: 359.000
EL: 179.999
Seems simple enough.
just means a bigger state machine, no biggue
*biggie
also, wouldnt have to worry about string formatting, and chopping + strcat()'ing a bunch of crud together
i think thats gunna be my answer
instead of a 4state machine, it has 8steps now
Fortunately all the steps do pretty much the same thing, so a little arithmetic will find the current set of numbers to display, and can call a common display routine.
yup
update the current time. do the orbital math. if state1, show time/date. if state2, show azimuth/elevation. if state3, show range/speed
if 5 seconds have elapsed, state++
Looks good to me.
STSPLUS
Plate o Shrimp - that was a year ago. ;)
Probably a screencap of a DOSEMU window.
One of other views (three views iirc).
the 'Program 2' header. i have that info + more, working. they formatted it pretty for the website, but i gotta handle it myself
overthinking again. 8lines of info. not 16
still only need a 4state machine
that webpage reads like the sdp model works, and i can track planets too, which is why i chose it. but i havent tried it yet. only playing with satellites for now
I've accidentally viewed satellites in my (old) telescope (which I no longer have).
It's very weird to see the white dot move at that rate in a telescope.
ive owned a nice telescope. in the early 80's my uncle had a cheap-o that let me see craters on the moon. ive also been to a nerd night at a local observatory, and i got to see a blurry image of saturn
*ive NEVER owned a nice telescope
They had a good one at the planetarium and took us up to the roof to view through it after the planetarium show.
ive seen the ISS pass overhead with my nekkid eye tho
They said they had a cement pillar built from the rock below the building and the building was designed to not touch the pillar. :)
not touching the foundation? i would think they want very solid foundation. is that for vibration?
gotta be
gunna go down for a cig, and grab a beer while im out. be back in like 10-15
Hehe.
I envisioned it as like an elevator shaft - a space in the middle of the building, spanning many floors.
There was no shake in the image at all, through that telescope.
I showed my mother Saturn in a 4" telescope. She became very afraid.
I had to explain to her that it was there long before she was born, and no, it wasn't going to come crashing down on us.
I saw Saturn when I was about nine or ten with thirty other students, so that kind of thought never had crossed my mind.
April 8, 2024
I'm going to fly my Lear jet to Nova Scotia. ;)
https://en.wikipedia.org/wiki/Solar_eclipse_of_April_8,_2024
i think i was 9 or 10 when i saw saturn too
no shake, and there was an actual eyepiece for me to use. telescopes these days dont usually have an eyepiece
all i remember is that it was blurry. i saw that there were rings around it, but it was pretty much just a brown blob lol
lol
We were allowed outdoors during the event, unsupervised. ;)
to be fair, im only 37. not THAT old
way older than the usual chatroom folk i encounter tho, so im still 'an old'
Misuse of 'old' five yards, defense.
lol
I remember .. um .. things .. about age 37 so sure, go ahead. ;)
most of the chatrooms i encounter, im easily a decade older than most, so 'an old' is fair in this context
i know you have me beat tho 🙂
Pretty sure by 27 you can fly fighter jets for the Air Force, if that's any help.
27 seems high
enlist at 18, finish classes by 20-22, then start the experience/flight hours phase
im not .mil, so just guessing
18 you can smoke and tell ur parents 'no'. 21 you can drink. 25 you can rent a car, and buy liquor in jamaica. after that its all downhill
It's kind of weird because the Flight Line is its own subculture. I was sent over there one day and was surprised to see they didn't wear the same uniforms we did.
i was climbing radio towers 31-34, and i was too old for it
i was better than my younger team, but its still more of a young mans sport
Hehe, it's pretty high up there.
my average worksite was 200-300ft. highest job was 600. highest tower i ever climbed was 800-820ish, and i went to the top just to say i did it
ill claim 800ft highest climbed lol
highest work performed was 600 tho
job is done @ 600ft. upload photos, wait for sprint/at&t to approve it. im gunna head to the top while we wait, just for a selfie
lol
when i unplug and then replug the USB cable that goes to my Metro Mini, whatever was on the 8x8 LED matrix i have hooked up to it before unplugging it is redrawn to the display before my sketch actually gets reloaded into memory.
i'm already drawing a "splash screen" of sorts to the display in the setup() function of every sketch, so it'd be nice if i could stop the old draw from happening
so is there a way to make the display come up empty immediately after power-up? or is this the result of some deep-set Arduino behavior i'll probably have to live with
It’s not Arduino behavior. Do you have a link to the led matrix you’re using?
it's this one, from Adafruit https://www.adafruit.com/product/871 @surreal pawn
It doesn’t look like the library does anything to the display if you don’t ask it to. You could clear or set brightness to zero in setup() but that is about the best you can do
The display will still show the old image before setup()
yeah, okay
although that did help me figure something out. apparently setting matrix brightness to zero immediately after a call to matrix.begin(0x70) will draw the old image but only for a small fraction of a second
so that probably works better than anything else :p
The datasheet says that the display is disabled on powerup. It's getting turned on by the begin() function call as part of blinkRate().
You could try commenting out the call to blinkRate() in Adafruit_LEDBackpack.cpp, clearing the display, and then enabling the LEDs yourself.
@lilac mountain
good call, i'll try that tomorrow
in any case thanks both @surreal pawn @rocky igloo
How can I change the brightness of the neopixel?
I am getting blinded
nevermind got it
If you're using the NeoPixel library, the .setBrightness() method ought to help.
@wind drift @north stream It’s often more performant and more accurate to do it yourself, instead, by multiplying your RGB values by a brightness fraction.
Yes I lowered my rgb value
But is there a limit to how dark it can be?
I went from between 50 and 25% I did not notice much difference
Some possibly useful information here: https://learn.adafruit.com/led-tricks-gamma-correction
@wind drift Yep! The perceived brightness is non-linear. You can often save a lot of power by scaling your RGB values way down. The gamma correction above is good reading.
Another great Adafruit guide is Sipping Power with NeoPixels:
https://learn.adafruit.com/sipping-power-with-neopixels
I have to wonder if the bootloader can be made to send a couple of commands to the running target system (say: RUN vs STOP).
Selectable at runtime via the /RESET PB switch - similar to double-clicking and what that does, now.
Or, is it more like a GOTO <addrs> with zero effect on the future history of the system, after <addrs> is read (and the code there, executed).
ughhhhh i've been fighting with this for so long i might as well just ask
how can i set up a uint8_t array in a .h file, then actually set its value within the corresponding .cpp file?
the catch is that it has to be initialized with static const uint8_t PROGMEM
(i think 😬 )
trying to set myself up to be able call the drawBitmap() function of the Adafruit GFX library, if that helps this make more sense
I’m not an expert but you made it a constant?
it has to be a constant, otherwise i can't load it into PROGMEM
and setting its value inside the public block of the .h file doesn't seem to work
@lilac mountain Which microcontroller are you using? I believe that you can't set PROGMEM variables at runtime, only at compile time. But something like an M0 or M4 board, especially an Express version, with onboard SPI flash, would give you more flexibility.
you can declare it extern in your .h file then implement it in your .cpp file
this way you can refer to the global variable from multiple cpp files but it only has one storage location: corresponding to the one in your cpp file where you actually initialize it
i'm using the Metro Mini @north kelp
Can you try what @surreal pawn suggests? I haven't tried it, but it sounds like a good idea!
sketch.ino ```C
#include <avr/pgmspace.h>
#include "mem.h"
void setup() {
Serial.begin(9600);
Serial.println((const uint8_t) pgm_read_byte(&array[2]));
}
void loop() {
}```
mem.h C extern const uint8_t PROGMEM array[];
mem.cpp ```C
#include <Arduino.h>
extern const uint8_t PROGMEM array[] = {1, 2, 3, 4, 5, 6, 7, 8};```
Output 3
let's see
sketch.ino
#include <Omega.h>
Omega omega = Omega();
void setup() {
omega.init();
omega.splash();
}
void loop() {
}```
Omega.cpp
Omega::Omega() {
extern const uint8_t PROGMEM _splash[] = {
B00000000,
B00011000,
B00100100,
B01000010,
B01000010,
B00100100,
B01100110,
B00000000
};
}```
Omega.h
class Omega {
private:
extern const uint8_t PROGMEM _splash[];
};```
i'm writing it like a library
you've declared it as an instance member variable inside an instance of the class Omega. I don't think you can use PROGMEM that way
extern const uint8_t _splash[];
^
C:\Users\sporeball\Documents\Arduino\libraries\Omega/Omega.h:29:42: error: flexible array member 'Omega::_splash' not at end of 'class Omega'
C:\Users\sporeball\Documents\Arduino\libraries\Omega/Omega.h: In constructor 'constexpr Omega::Omega(Omega&&)':
C:\Users\sporeball\Documents\Arduino\libraries\Omega/Omega.h:29:42: error: initializer for flexible array member 'const uint8_t Omega::_splash []'
C:\Users\sporeball\Documents\Documents\Code\GitHub\project-omega\sketches\Snake\Snake.ino: At global scope:
C:\Users\sporeball\Documents\Documents\Code\GitHub\project-omega\sketches\Snake\Snake.ino:3:21: note: synthesized method 'constexpr Omega::Omega(Omega&&)' first required here
Omega omega = Omega();
^```
knocked PROGMEM out of both of the declarations and it still throws this ^
yeah, it will have to be a pointer in your header file
i.e.? @surreal pawn
header file:
extern const uint8_t * const sfx;
cpp file:
const uint8_t sfx_raw[4352] PROGMEM = {stuff} const uint8_t * const sfx = sfx_raw;
if you can copy the size in the header and cpp file then you can just make it an extern array of fixed size but in my case I can't.
so that'd be something like:
foo.h global const declaration:
extern const uint8_t myarray[128];
foo.cpp global storage + initialization:
const uint8_t myarray[128] PROGMEM = {stuff};
it's still throwing the whole storage class specified for '_splash' thing
extern const uint8_t * _splash; maybe
no dice
Storage class error still or some other error?
storage class error
Hrm. Maybe punt extern and/or const, those are the only storage class modifiers left: it could be that using old C-style modifiers doesn't play nicely with C++ style classes.
are you still trying to declare this inside your class?
yeah
I needed extern const in the declaration in both the .h and .cpp files. It wouldn't compile without them.
without const or extern the Adafruit libraries are throwing 5 errors at once
I don't think you can declare progmem instance members
yeah because your class needs to define exactly how large that array is because it's an instance member
Not sure where you're code is now @lilac mountain but up above you've got _splash[] inside the constructor member function Omega::Omega(). That seems unlikely to work.
guess i get to declare static const uint8_t PROGMEM splashData[8] solely within Omega::splash()
well this was a rollercoaster from start to finish
and i can still write to the display by making it public, then using omega.matrix...
this works
one more function to write and then i think i'll be finished with the library 🎉
thanks everyone for helping out owo
@lilac mountain if it's not needed outside your class it could just live in the cpp file only as a global there... yeah similar to making it a static variable inside of the function
.h
#pragma once
class Omega
{
public:
Omega();
void init();
void splash();
};
.cpp
#include <Omega.h>
#include <stdint.h> // uint8_t
#include <avr/pgmspace.h> // PROGMEM
// only available in this cpp file:
const uint8_t _splash[] PROGMEM = {
0b00000000,
0b00011000,
0b00100100,
0b01000010,
0b01000010,
0b00100100,
0b01100110,
0b00000000
};
Omega::Omega() {
}
void Omega::init() {
}
void Omega::splash() {
// use _splash here
}
Unless you're expecting to have multiple Omega object instances and different bitmap data for each of them, where the data is declared isn't much of an issue.
I'm not using Arduino.app so B0000000 didn't build for me
ahh gotcha
that is pretty much what i'm doing now actually
although i'll note that if i don't declare _splash[] as a static then the screen outputs a bunch of garbage data o.o @surreal pawn
odd
I don't know what your code looks like at that point, but I'd bet you've got two different storage locations with the same name that aren't the same place
as in, one is a local variable of that function, and another is an instance or global variable you never initialize
i did narrow it down. it only seems to output garbage data if i declare _splash[] as a non-static const within Omega::splash()
any other style seems to work fine
now we know i guess :p
i am 100% new to all this! is it possible to fry parts going under amp or could I have just gotten a bad part; am i doing something else wrong? i think, i had a node mcu (i am pretty sure the node mcu is fried because it won't power up or connect when plugged into computer anymore) and 5v led powerstrip, go out on me... it was only being supplied 1amp, at the time. i have a 12volt power supply with a 12v-5v (3amp, according to spec) step down going to 5v led strips... 5v/3 amp would probably be perfect (i think) but i only get 5v/1amp. would my led strip just not work in this case? would a proper 5v power supply fix my problem?
yes, connecting 5v or 12v on the wrong nodemcu pin could toast it with less than 1 amp of current
stepping down from mains to 12V then 12V to 5V isn't so bad that you should avoid it
you can definitely connect more 5V neopixels than you can drive with only 3 amps at 5V. I think very roughly that'd be over a hundred though
i have a 5v power supply and a new led strip coming... i am optimistic i'll get it working then.
i am learning
huh, how long has platformio had the "inspect" feature?
someone finally built the breakdown of "where is my ram and flash going" and it's already in platformio
platformio inspect summary
Does anyone know how I can get the battery percentage on an itsy bitsy?
some of the boards the arcada library supports have an analog input used as a battery sensor
hallowing m0 schematic. VBATT goes to A6 input
the resistor divider is because a single cell lipo is often above the 3.3V for the samd21 logic level
here's the code to read the voltage. It assumes 3.3v analog reference and 1:2 divider: https://github.com/adafruit/Adafruit_Arcada/blob/c9a039d770ec2b1e6c5c7671d0dfb77da8334b65/Adafruit_Arcada.cpp#L586
I don't know if you're using the 5V itsy bitsy or the 3.3V one
Got a code question again.
I want to have my barcode scanner scan while I hold a button down.
However when I press the button just once it should print something for around 5 seconds and then stop
during the 5 seconds if I hold the button again it should scan again
and so on
Serial.println("scanning");
}```
while (digitalRead(button) == LOW) {
Serial.println("scanning");
ButtonActive = true;
}
if (ButtonActive == true) {
lastScanButtonTime = millis();
currentScanButtonTime = millis();
while (currentScanButtonTime - lastScanButtonTime < 500) {
Serial.println("RFID");
currentScanButtonTime = millis();
ButtonActive = false;
while (digitalRead(button) == LOW) {
Serial.println("scanning");
ButtonActive = true;
}
}
}
}```
Okay kinda got it to work
#define SECONDS(x) (x * 1000)
static bool scanning = false;
static unsigned long endscan;
void loop()
{
unsigned long curtime = millis();
if (digitalRead(button) == LOW) {
if (!scanning) {
Serial.println("scanning");
scanning = true;
}
endscan = curtime + SECONDS(5);
}
if (scanning && (curtime > endscan)) {
Serial.println("end scanning");
scanning = false;
}
}
Thanks - but it's not exactly the one I am looking for.
While holding the button it should loop and print "scanning"
If I only tap the button once it should NOT print scanning
Instead it should loop for 5 seconds and keep printing "RFID"
But if I hold the button during the 5 seconds it should print the scanning like before
Whoops, I misunderstood
@north stream ```void loop() {
startScanTime = millis();
while (digitalRead(button) == LOW) {
Serial.println("scanning");
ButtonActive = true;
lastScanButtonTime = millis();
}
if ((ButtonActive == true) && (lastScanButtonTime - startScanTime > 1)) {
currentScanButtonTime = millis();
while (currentScanButtonTime - lastScanButtonTime < 500) {
Serial.println("RFID");
currentScanButtonTime = millis();
ButtonActive = false;
while (digitalRead(button) == LOW) {
Serial.println("scanning");
ButtonActive = true;
}
}
}
}```
I gave this one a try
but not really working
It still prints the rfid even after a long press
if ((ButtonActive == true) && (lastScanButtonTime - startScanTime > 1))
I don't really follow what your intended behavior is.
Well basically I want to scan a barcode while I am pressing the button.
And when I just tap the button it should activate an RFID scanner and scan for a period of 5 seconds
I thought if ((ButtonActive == true) && (lastScanButtonTime - startScanTime > 1)) could handle the part where it checks if the button has only been tapped once
So when the button is first depressed, it goes into "scan barcode" mode. Then when it's released, it should switch to "RFID" mode and stay there for 5 seconds, then go to idle?
While the button is pressed down it should be in scan barcode mode. When you release it it should idle.
When you only tap the button for a second it should go into RFID mode and scan for 5 seconds. Then should idle
With my current setup it goes into RFID mode even if I have pressed the button for a long time
And I have one other problem
the barcode and rfid scanner both use SoftwareSerial
I know that I have to use https://www.arduino.cc/en/Reference/SoftwareSerialListen
Open-source electronic prototyping platform enabling users to create interactive electronic objects.
but it does not respond when I try the islistening command
#define SECONDS(x) (x * 1000) // convert seconds to milliseconds
#define SHORTPRESS 700 // max time for a short press
static bool scanning = false;
static bool rfid = false;
static unsigned long startpress;
static unsigned long stoprfid;
void loop()
{
unsigned long curtime = millis();
if (digitalRead(button) == LOW) {
// button pressed, go to barcode scanning mode
if (!scanning) {
Serial.println("start barcode scanning");
scanning = true;
startpress = curtime;
}
}
if (scanning) {
if (digitalRead(button) == HIGH) {
// button released
Serial.println("stop barcode scanning");
scanning = false;
if ((curtime - startpress) < SHORTPRESS) {
// short press, switch to RFID mode
Serial.println("start RFID scanning")
rfid = true;
stoprfid = curtime + SECONDS(5);
}
}
}
if (rfid && (curtime > stoprfid)) {
Serial.println("end RFID scanning");
rfid = false;
}
}
Does the .isListening() method not return or what?
Yes it does not return any print
but I also tried the exact same example code
my arduino crashes when I try to open the terminal
Maybe there's a bug in SoftwareSerial or your Arduino is an unusual one?
Adafruit Feather nRF52840 Express
Error setting serial port parameters: 9,600 N 8 1
22:52:09.841 -> stop barcode scanning
22:52:09.841 -> start RFID scanning
22:52:10.320 -> start barcode scanning
22:52:10.561 -> stop barcode scanning
22:52:10.561 -> start RFID scanning
22:52:10.561 -> start barcode scanning
22:52:10.561 -> stop barcode scanning
22:52:10.561 -> start RFID scanning
22:52:11.072 -> start barcode scanning
22:52:11.209 -> stop barcode scanning
22:52:11.209 -> start RFID scanning
22:52:16.221 -> end RFID scanning
Is what I get with the code above
when I press/release
Hi there, I have some really long (150+ lines) Arduino code that seems to be very inefficient too. Is there anyway I can shorten the code/make more efficient?
http://txt.do/1o0mf
#include
Adafruit_Arcada arcada;
#define MAX_FILENAME_PATH 255
char filename_path[MAX...
@north stream @wind drift SoftwareSerial may not be a reliable option on nRF52840. It isn't on nRF52832. See this Forums post:
https://forums.adafruit.com/viewtopic.php?f=54&t=153712&p=758466#p758466
…and this issue discussion:
https://github.com/adafruit/Adafruit_nRF52_Arduino/issues/243
Software serial bit banging is corrupted when BLE is adverising https://forums.adafruit.com/viewtopic.php?f=57&t=147186 nrf52832 feather Software 0.9.03 bleuart example software serial @ 96...
any idea on how to check polling rate of arduino on windows?
What are you polling, @worn bison?
an arduino based game controller (DDR)
needing 1khz polling.
i know the sketch is good because i verified it some time ago in linux with evhz but now I am using windows because (reasons) and am looking for a way to verify polling in this environment @north kelp
@worn bison I found some discussion of game controller polling rates here, along with possible tools to test them:
https://forums.guru3d.com/threads/anybody-know-what-polling-rate-xbox-controllers-use-on-windows-10.422404/
i have ds4windows but the controller doesnt show up
i used to use this
but i think someone had to help me tweak it slightly to work with the arduino keyboard based controller
then i had to mash the buttons and look for polling rates at or around 1000hz
I sort of got my problem with my barcode and rfid scanner working
But I am a bit confused why the print order is not correct?
after 'scanning' it should print the barcode
how many times does it go through that code during the 50 milliseconds it waits before printing the barcode. Each time does, it will print the lines you see.
Ah I see what you mean
Okay another problem
startScanTime = millis();
if (digitalRead(interruptPin) == LOW) {
lastScanButtonTime = millis();
pinMode(interruptPin, INPUT);
unsigned long curtime = millis();
barCodeSerial.listen();
if (barCodeSerial.isListening()) {
// Serial.println("scanning");
lastReadTime = millis();
while(barCodeSerial.available()){
// delay(5);
code += (char)barCodeSerial.read();
//Serial.println(code);
inString = true;
ButtonActive = true;
}
}
}
uint32_t curReadTime = millis();
if (ButtonActive == true && inString == true && curReadTime - lastReadTime > 10) {
if (scanmode == "adding"){
Serial.println(scanmode);
Serial.println("BarcodeID:");
Serial.println(code);
code = "";
inString = false;
ButtonActive = false;
}```
So currently the barcode is reading fine
What I would like to happen is that when I press the button AND there was no code pasted it should print something
But I am not sure where to put the code
I tried to put it as an else behind isListening but it didn't help
Probably check for the button no longer active and inString still false?
Ah yes got it to work now
Okay - last thing but I am not sure how to fix that.
Currently it will print the barcode after I have released the button. Is there any way to let it print when it received the whole code even when I am still holding the button. (I know that the light turns off on the barcode scanner when it has read the code
at the moment I only have this one connected
If the barcode reader sends some sort of "end of code" character (like a null or carriage return), you can check for that and print it then.
Alternatively, you can set a timer when you receive a character and when a certain amount of time has elapsed without any new characters, go ahead and print the barcode
I cannot see any special character from the terminal unfortunately. (Unless it's somehow invisible?)
I think the second option will be a bit complicated if it's a longer barcode, no?
Maybe I can somehow use the pin 10 LED to detect if it scanned something?
Right now the LED at pin10 is ON when in idle. And when it scanned it turns off for a second.
I hope it's OK to share this here. A bunch of people have helped me over the past week or two on LED based project I'm working on, and it's finally done, so I created a demo video https://www.youtube.com/watch?v=aaXFCma1wlk a link to the code can be found in the description. Thank you! (if there's a better place for me to post, just let me know)
Code can be found here: https://github.com/nruffilo/BitsnBots/tree/master/InteractiveLight Uses an adafruit Trinket m0 https://www.adafruit.com/product/3500 ...
A transistor I assume?
Might be able to do it in code, but a transistor is also a possibility.
With the "time since last character received" algorithm, the length of the barcode is not important.
The LED may not be in synch with the serial data, I'd stick with the .available() method
I suspect the -1 results are "read failed because of no data"
Okay - I thought maybe I can determine the end character here
Most barcode readers are configurable as to what (if anything) they send for an "end of barcode" delimiter.
Failing that, the "time since last character received" approach should work.
"(Level)Key Holding
Press the button to trigger the reading, release the button to end the reading. Reading success or reading time over a single reading time will end the reading.
"
#define MAXBARCODEDELAY 70
unsigned long curtime = millis();
bool waiting = true;
while (buttonpressed && (waiting || (curtime < timeout)) {
if (barCodeSerial.available()) {
code += barCodeSerial.read();
waiting = false;
timeout = curtime + MAXBARCODEDELAY;
}
}
Then use the "look for pause between characters" approach.
Hm I got a prefix now
Looks like the right ones.
page 66
and it works
I used this one before
but for the suffix I guess I am doing something wrong
I scan these
but not helping somehow
If I read it right, you need to scan the Suffix 1 code (50C006) followed by four numeric digits to specify the code to send. Then scan the transmission format code for data + suffix1 (20C1001). Then it should send the barcode data, followed by the character described by the 4 digits you scanned.
Perhaps 50C006 + 0 + 0 + 1 + 0 to set suffix 1 to a linefeed.
I gleaned that from the wording "To set these values, scan a four-digit number (i.e. four bar codes)"
Apparently there's a way to do it via serial commands as well, but scanning bar codes seems simple enough.
Hm just tried again but it does not seem to work
not sure if I need some kind of 'save' function after the 4 codes
I'm making a project that uses the vs1053 adafruit shield to play music for a spinning christmas tree I made. I have LEDS attached to the tree, but I want them to interact with the music. For example, the lower tier of lights would pulse every time the bass is hit on a drum set in a song, and the upper tier would blink everytime the hi-hat is played. How would I got about doing this? In my head it seems simple but I don't know how to code it. Any help would be appreciated.
Here's a link to a resource for vs1053 Class Reference https://mpflaga.github.io/Arduino_Library-vs1053_for_SdFat/classvs1053.html
Hey guys! I want to make a physical youtuber subscriber clock for one of my friends.. Someone told me that it may not be possible anymore with youtube's new subscriber display methods so wanted to ask you for any advice!! how should I go about it now? or is it just not possible! (I'm kind of a newbie) thanks
Looks like the API supports it: https://developers.google.com/youtube/v3/docs/subscriptions/list?apix_params={"part"%3A"id"%2C"mySubscribers"%3Atrue}
Hm I finally got a Prefix working for my barcode scanner
but suffix still no luck
weird
Weird indeed.
I wonder if it's in mode 2C1004 (prefix+data) instead of mode 2C1001 (data + suffix 1)
Okay I now tested all of those codes
apparently prefix+suffix1+suffix2 is working
prefix works
but all the other ones not
That's annoying, but you can just use prefix+suffix1+suffix2 (or go back to "time since last data sent")
Yeah I will go for the prefix+suffi1+suffix2
And something I am a bit confused about is apparently it can scan "qr codes"
But I wonder how? Since the light is a horizontal beam
and QR codes are square shaped
Most of the 2D scanners are imaging scanners. The light you see isn't really used by the scanner, it's just an aiming aid so you know it's aligned on the barcode.
how are you playing sounds now?
I'm doing some tests with a https://www.adafruit.com/product/3317 to try and sense when a fast moving object moves. if i move it by hand it senses it, but when it moves for real (compressed air powered) its too slow to catch it. any ideas?
The VL53L0X is a Time of Flight distance sensor like no other you've used! The sensor contains a very tiny invisible laser source, and a matching sensor. The VL53L0X can detect ...
I'm using Adafruit_VL53L0X to access it
using a feather m0 arduino
does your object move out of view in 33ms?
@surreal pawn potentially
I think you'll be better off building a chronograph which has a pair of infrared sensors a measured distance apart and measures the time it takes from the first sensor to change to when the second sensor changes
there are several examples on instructables: https://www.instructables.com/howto/chronograph/
@knotty rover In general, oversampling is the answer.
EDIT: much longer set of musings given in-channel. Deleted, and recopied to a text file (see below).
That sensor outputs via i2c so is limited in a way related to i2c bus speed.
The (brief!) sample code given shows how to sacrifice the one for the other.
I would paint the target object with an emissive and use that object as an obstruction to a sensor on the other side of it, which detects a broken beam.
sense when a fast moving object moves
20 ms = 0.02 seconds
Thanks, I'll do some more tests and check back in
I would think you would need at least two samples to have information, not just a singleton.
Time of Flight - musings (originally in-channel) by @pine bramble
https://www.st.com/resource/en/user_manual/dm00279088.pdf
User Manual for this device's API.
2.6.2 The typical timing budget for a range is 33ms (init/ranging/housekeeping), see Figure 12,
with the actual range measurement taking 23ms, see Figure 9. The minimum range
measurement period is 8ms.
Time of Flight - musings (originally in-channel) by @pine bramble (Revised).
thanks for the feedback. my issue ended up not being sampling rate. I had another error in the related code, and the distance sensor is catching what I was looking for
super basic question - is there a different/which is better (power consumption wise) having a button wired from an Analog/digital pin, to button, then to ground and setting it to PULLDOWN (is that the right one) or having the button between 3.3v, then the button, then the analog/digital pin and setting it to pullup?
i'm running it with a Trinket M0, which, like the arudino boards, have pulldown/pullup resistors
Either way works. I tend to use pullup and grounding switches, as that's the only arrangement some other processors support. Some folks like to use pulldown and a switch to Vdd, so a closed switch is a "1" and an open switch is a "0". From a power consumption standpoint, it matters little, but you can try to arrange it so the switch is open more often than closed if you're trying to save the last nanoamperes of current.
I think I've seen more datasheets that a lot of microcontrollers can sink(pulldown) more current than they can source but the total amount going through the button shouldn't change. and Pull up or downs shouldn't get you anywhere near the total chip current limits
I do remember that TTL circuits can pull down much more strongly than they can pull up, didn't realize some microcontrollers were like that too. I wonder if it's just tradition (like switching to ground in vehicles because the chassis is grounded and it's easy to do) or N-type transistors are smaller/easier to fabricate.
How can I check if a string contains a number?
0-9
Currently have this one if no barcode is found
if (code.substring(1) == "BNR") {
Serial.println("No Barcode detected");
}
Okay found a workaround but now another problem
pinMode(interruptPin, INPUT);
barCodeSerial.listen();
if (barCodeSerial.isListening()) {
while(barCodeSerial.available()){
code += (char)barCodeSerial.read();
}
}
}
if (code.startsWith("+BNR") == true) {
Serial.println("No Barcode detected");
Serial.println(code);
code = "";
}
else if (code.startsWith("BNR") == false && code.endsWith("*+") == true) {
Serial.println("Barcode detected");
Serial.println(code);
code = "";
} ```
When it reads a barcode it immediately prints it after I release the button
But for the no barcode detected it only prints after I have pressed it a second time
Why is that?
Hmm, you set it to "listen" mode and then check if it's in "listen" mode, that seems unnecessary, but probably isn't the problem.
I'm also not sure why you set the pin as an input after reading from it (as an input)
Ah yes forgot to remove that
I removed the islistening and pinmode part
but still the same problem
barCodeSerial.listen();
while(barCodeSerial.available()){
code += (char)barCodeSerial.read();
}
}
if (code.startsWith("+BNR") == false && code.endsWith("*+") == true) {
Serial.println("Barcode detected");
Serial.println(code);
code = "";
}
else if (code.startsWith("+BNR*+") == true && code.endsWith("*+") == true) {
Serial.println("No Barcode detected");
Serial.println(code);
code = "";
} ```
Even if I do it like this
Probably down to the behavior of the barcode reader, there's probably a delay before it says there's no barcode.
May need to move the .available() loop outside the digitalRead() test so it keeps trying it (in which case you probably want to wrap that in the .isListening() test again)
Ah yes moving it outside the loop kinda helped
Okay seems to work so far
barCodeSerial.listen();
}
while(barCodeSerial.available()){
code += (char)barCodeSerial.read();
}
if (code.startsWith("+BNR*+") == false && code.endsWith("*+") == true) {
Serial.println("Barcode detected");
Serial.println(code);
code = "";
}
else if (code.startsWith("+BNR*+") == true) {
Serial.println("No Barcode detected");
Serial.println(code);
code = "";
} ```
Thanks!
onto finding my next problem
Does someone know why i have this error: Timed out waiting for packet header. when i try to upload code to my esp? This error appear when i solder some things to my esp, here is my wirings:
I can hear that speaker buzzes when i try to upload code. Or maybe this is one of modules, like gps modeule? I am not sure.
it's probably the GPS. uploading code happens over the uart (rxd/txd) so actually using those pins will confuse it.
Especially a uart GPS module, which is going to be chattering GPS data in the middle of what should be your program. You'll probably need some sort of connector so you can easily disconnect the GPS when programming
tldr; how do I wipe the memory (spi flash?) on a Feather M0.
I'm using a Adafruit Feather M0 WiFi with ATWINC1500 and the Wifi101 library. I've used the provisioning example to connect to it as an AP and then enter my SSID/pwd. That's all working fine but I'd like to be able to clear the SSID/pwd from the device so I can test more easily. I tried to use the Adafruit SPI Flash Total Erase but get the error "Error, failed to initialize flash chip!". Am I on the right path or should I be trying something else? Thanks!
@Luminescentsimian, I solder switch between 3.3v pin and all of my modules - now it is uploading, so i hope this was a problem, becouse i dont want to unsolder everything. It is working for now, so thank you for your help.
i'm testing out my speaker by looping over the following lines
omega.speaker(NOTE_C4, 100);
delay(100);
omega.speaker(NOTE_E4, 100);
delay(100);
omega.speaker(NOTE_G4, 100);
delay(100);
omega.speaker(NOTE_C5, 250);
delay(1200);```
the NOTE values are defined in the header file, and omega.speaker() is just defined like this
void Omega::speaker(int freq, int ms) {
tone(11, freq, ms);
}```
however what i can't figure out is why the last two notes in the sequence tend to falter and output unexpected tones about 50% of the time
any ideas?
I don't see how it could be other code interfering with the Arduino, so I'm wondering if there's a mechanical resonance that's making a connection intermittent at those particular frequencies, or perhaps some sort of electrical kickback.
no idea
but apparently if i call delay(ms) right after tone() in Omega::speaker(), instead of right after each speaker() call, the problem totally goes away o.o
i'll probably have to use millis() just so the program doesn't fully stop
@north stream
Hmm, could be some sort of weird timer conflict if delay() and tone() use the same timer? Just guessing at this point.
Howdy guys, quick question. What is the easiest way to have Adafruit Feather 32u4 Bluefruit LE play audio files through a speaker? Would like to have a way to play certain files from the Adafruit app.
Music Maker FeatherWing is very easy to use. https://www.adafruit.com/product/3436
@pure coyote
http://adafru.it/3010
ATSAMD21 + ATWINC1500
The wifi chip is an SPI peripheral; this is an ordinary SAMD21 (G18A) target board with a WiFi peripheral soldered onto it
@pure coyote I'm guessing the WINC1500 may have a small storage area in it, so to erase that you'd be talking over the SPI bus, from the SAMD21 chip (SAMD doin the talkin)
So you wanna learn the API that talks the language the WINCE chip understands.
https://learn.adafruit.com/assets/32983
Reading the schematic it became obvious what the attached storage was (no storage peripheral chip on this target board) and what the protocol was (SPI) to talk to the WINCE chip.
This page is going to say the basics of talking to the wifi chip:
https://learn.adafruit.com/adafruit-feather-m0-wifi-atwinc1500/using-the-wifi-module
@pine bramble thank you. That makes a lot of sense and I didn’t think to explore that avenue. I appreciate the context too. I’ll check it out later this week.
https://github.com/arduino-libraries/WiFi101/blob/master/src/spi_flash/source/spi_flash.c
Maybe the WINCE datasheet can shed some light on why this flash code is present in the repo. ;)
(The market may have a target board with external SPI flashROM. Not sure it makes sense to think of the WINCE chip as having an 'internal' spi flashROM.)
Could very well be that while the Adafruit vended target has no external spi flashROM, some other vendor's work does. I don't know. ;)
Good place to dig for background. ;)
@pure coyote looks bingo-ish to me:
https://github.com/arduino-libraries/WiFi101/blob/master/src/driver/include/m2m_wifi.h#L836
and I'm back quiet.
I am still here and I am still looking for help please.
How can I sue the ADXL345 with my code ?
This is my code
Can someone please tell me the lines of code needed to use the 2 new ADXL345 accelerometers , in place of the 2 old GY6050 ?
Thanks
hey, please excuse this question sounding kinds dumb... but if I have an atmega running an i2c screen and it's already borderline starting to run a little slower than I'd like.... if I add a second screen and give it display instructions as well it will significantly slow down the program as well, yeah? Using ssd1306 and sh1106 screens with the adafruit library, and addon for the sh, and adafruit_gfx if that matters...
You should be able to use SH1106 one with SPI, which is much faster and can use hardware acceleration
I didn't realize sh1106 came in spi too, I'll have to look into that, I have tons of pins. The extra physical size of the 1106's is nice
at least, the onses I've been messing with. I think I've got 1.3" instead of the .96" and they fit well... they're just slower than my ssh1306 spi stuff
I have made some modifications to Adafruit_MP3, which is an Arduino library. Can someone point me at a guide for how to build locally with my version of this library?
You just make sure your files are the one in /documents/adruino/libraries/thelibrary
will this location risk being overwritten if the official Adafruit_MP3 library gets an update?
yes, but I think as you don't manually update it in the ide you should be okay... I think
I would keep a backup just in case
okay, by habit I keep all my git clones under ~/src so I can just copy it into place as needed I guess
thanks, I'll give this a whirl!
You can also include the files in your build directory but you might want to rename it in either case to avoid conflicts with the existing library
You can make a softlink from arduino/libraries to your git clone (I do this a lot)
avrdude may pick the wrong one when compiling if you don't rename it from what I understand, ya?
I suppose if I don't install it from the library manager then it won't update via library manager either? I don't know much about how this works.
You may also get "multiple libraries found" complaints (I get those a lot too)
jepler, I think you're correct. If it's not installed in the ide it wont try to update it
I'm not sure if the ide has auto updates off the top of my head tho... I know i have to use old i2c libraries to run screens faster and it doesn't ever override them once i pick a version
one of my $10 1284 chips seems to be burned out 😦 Keeps returning a serial of 0x000000
Are sure it's set up properly?
can someone help me use an IL9341 featherwing TFT to post cereal data from projects?
Well hello! I am trying to create a pressure sensor using pressure sensitive clothe and velostat. I've got code made that basically shows the difference from analog port 0 to ground (positive negative) but I'm such an amateur, heh. I just took the pins and poked them through the cloth, and I'm not using a resistor at all in this, but I don't know if that is necessary or not in this case. I would like to know what kind of resistor would be necessary for that if one would (it's arduino uno so 5v to ground currently). If anyone just likes speaking arduino or has a great guide for it that they like, I'd appreciate any information.
You probably do need a resistor (to the positive voltage supply), so you basically have a tug-of-war between the resistor pulling up and your sensor pulling down. Then the Arduino can measure the voltage between them and calculate how hard the sensor is pulling down.
The value of the resistor depends on the resistance of your sensor, but 10k is often a workable starting value.
There's a helpful writeup here https://learn.adafruit.com/force-sensitive-resistor-fsr/using-an-fsr
Any idea as to why I'm getting like 3633 PPM using the MQ135?
I'm using an esp32 feather
oh... uh it literally reads the same thing when I take the sensor off.
@simple horizon How's it connected to the esp32?
VCC to 5V, GNG to GND, AO to A0
It's working better now that I set analog read to A0 instead of 0 but it's 1653 PPM now
Is WiFi on?
no
Reason I ask, is that A0 is on ADC #2. “Note you can only read analog inputs on ADC #1 once WiFi has started”.
https://learn.adafruit.com/adafruit-huzzah32-esp32-feather/pinouts#gpio-and-analog-pins-2-15
I'd try A1 and change the code accordingly.
But it's not on ADC #1. I thought was literally just two pins
But I'll change it.
A0 is on ADC #2. A1 is on ADC #1.
I'm not trying to argue but it the pinouts say this
"A1 - this is an analog input A1 and also an analog output DAC1. It can also be used as a GPIO #25. It uses ADC #2"
Oh drat. My bad.
So try A2?
Yep. That's what I'd do.
When I put the pin into AnalogRead() do I use A2 or the GPIO pin of 34?
I'd try A2 first.
Hmmm. Looking at datasheet:
https://www.olimex.com/Products/Components/Sensors/Gas/SNS-MQ135/resources/SNS-MQ135.pdf
I think it might have to be a decimal issue? It don't know.
When I unplug it goes to 0 as it should.
This is my print statement "Serial.print(sensorValue, DEC)"
Yes it does
Yay! Progress.
This looks like it might be helpful:
https://www.youtube.com/watch?v=V1uOHOcVZrE
In this video, we use the MQ135 gas sensor to measure the concentration of carbon dioxide in the air. We know that the average CO2 level is 400ppm, so by doi...
There will probably be some scaling of the output numbers, since you're using ESP32 vs UNO. They have different analog reference voltages.
ya and I think he kinda takes care of that via mapping
He's using an UNO, which has 0-5V analog input. Your ESP32 analog inputs range from 0 to 3.3V, I believe.
So your numbers may be 1.52x higher. (I think)
still seems too high for it to be 1.52x higher
More discussion at:
https://community.particle.io/t/mq135-and-spark-core/12657/8
Hello, I’ve put some concepts about gases sensors here: Here is my sketch for the core, it pushes the values to a domoticz server on the local lan. The best to start is to have a MQ135 with a borard, and for the voltage I guess @peekay123 already said everything 😉 ...
but I'll follow this tutorial
I'd use caution with a 3.3V system, and disconnect from ESP32's analog input for now.
You may need a voltage divider (resistors) to scale down the output voltage on the sensor's A0 pin.
should I just go back to the arduino?
If there's a possibility of generating more than 3.3V from the sensor's A0 pin could damage the ESP32.
would a MKR VIDOR 4000 be sufficient?
jk I found my uno
lol
So now it says 255 ppm
Goes up to like 332 ppm when I blow on it
So about 4.4x higher on the esp32
Your code would have to account for differences in supply voltage, pull-up resistance, and digitizer reference voltage.
I think I'm just going to use the uno for now because this is just to get the values with little regard to value accuracy. I'm using it for processing
Quick question about DotStars. I'm in the early planning stage of a project that will involve multiple channels of DotStar strips. Is it possible to have all the strips share the same clock line? Just thinking of reducing pin counts.
I'm looking at the datasheet, and it looks like it should work? Start frame is defined as 32 0s down the line, and each LED starts with three 1s before the actual meaningful data.
I just don't know if after seeing the 32 0s, it just keeps waiting for valid data, considering every new 0 to be the "32nd 0" in the sequence.
Should be possible to share a clock, but many hardware SPI implementations only support one MOSI line. You may also need a buffer if you don't have enough fanout on a GPIO pin, and series resistors if reflections cause issues.
As for the zeros, I figure it's at least 32, and more won't change anything further.
Well, I'm going with DotStars in part because they specifically can be used on any two pins, hardware backed SPI or not. I hadn't thought about signal reflections, but I don't think they'll be an issue since everything will be terminated.
I don't know what you mean by needing a buffer for not having enough fanout. Is this just regarding the signal being strong enough for each strip?
Really this question is part of a "what if" scenario. I'm driving the lot with a Feather, so if I do nothing else, I can get 10 channels without sharing clocks. 9 if I want to monitor the battery pack (which I do). 9 channels is most likely plenty, but I like considering my options.
Yeah, just make sure the Feather has sufficient current drive capability to drive all that capacitance and all those inputs. Depending on your power supply layout, you may want level shifters, which would generally provide the buffering for you as well.
Oh there'll definitely be a level shifter in there.
I know for small things you can run DotStars off 3.3 with 3.3 logic, but I'll have them on 5v, so gonna get 5v logic to them as well.
off topic, and this part of the project is a c++ pi program, but i still wanna show it off
next step, send that data to the arduino to display, and move the motors
🙂
already got serial comms working between the 2, and spent a few hrs tonight text formatting so the numbers would show how i want, in 2x16 chunks 🙂
So... I've got two atmega1284s that started returning a signature of 0x000000 under different circumstances. The second one I have breadboarded with an external 16MHz crystal and have been flashing programs to it today without changing the breadboard at all except that one of the last programs I flashed to it I had it connected to 3.3v instead of 5v. Now I can't flash anything, hooked up to the ICSP pins, because of the signature.... Any ideas if this is recoverable?
I would really like to keep using these $10 chips.... expensive to brick 😦
.... I also don't get why this last one bricked if the only difference was the 3.3v, I've been making minor corrections to a program and reflashing
For reference, I've tried using an external power supply and tried swapping the oscillator crystal for a couple other ones just in case
I've also checked the resistance between VCC and GND and it's very high, in the M range
have you tried switching the fuse bits to use the internal oscillator too?
@proven mauve It's possible some bits got programmed to weird states: the usual way to rescue those is with a "high voltage" programmer that can reset chips that have gotten confused and don't respond to normal programmers. I normally use an STK500 for this, but there are other options out there.
@north stream @acoustic nebula So I did try to flash the fuse bits with avrdude back to the internal oscillator, owever it wasn't changing the bits, even with -F
madblogger, I have some unos and nanos laying around, and some pro micros too, as well as an adjustable power source, would any of that work as a high voltage programmer?
I'm on phone at the moment but try searching for "DIY high voltage AVR programmer "
will do, thanks for the tip!
You should check the chip data sheet and see if it supports serial or parallel high voltage programming - serial is generally easier if it's supported
kk
So the only mention is "The RESET pin accepts 5V active low logic for standard reset operation, and 12V active high logic for High Voltage Parallel programming. "
okay, I see.... and I see why parallel is a pita
It LOOKS like I can do this with an UNO, a 12v supply, a few 1k resistors, and a transistor.....
@north stream are you around?
I'm back now (was taking the cat to the vet)
I hope he's good to go!
I got to the very last steps of scratch monkey, and of course it's old enough to be incompatible with the IDE now
so after everything was wired and right before I hit burn bootloader I ran into problems getting it to list as a programmer, then when I got it to list it wouldn't run
So I swapped to the simple hvpp sketch, which runs over serial
I can get the initial menu up but it wont communicate after that 😄
So... what sketch and programmer settings do you use to HVPP?
I've got to get some sleep, but I will definitely follow up tomorrow to try and get these chips running again. I think this really may fix it
THanks again for the help!
I'd like to build a simple device that can access 28c64 or 28c256 EEPROM and for example dump it or write a .bin file to it. I thought about using an SD card reader, but I think it would be inconvinient to have to remove the card and put it into my computer to see the dump or to copy the file I want to write. Is it possible to send/receieve files over serial connection?
I don't think an SD card reader would help. You can write a simple sketch to read off the data with an Arduino and send it back over a serial link.
I'm actually toying with the notion of creating a custom shield to read EEPROMs and write FRAM and the like.
There's also https://github.com/beneater/eeprom-programmer
So it probably comes down to writing a program on my computer that either reads incoming serial data and puts it into a bin file or reads a bin file and sends it byte-by-byte over serial. Does that make sense?
Yeah. What I'd probably do is have the Arduino send the data in hexadecimal, then have a program that either saves it verbatim (and use an ordinary .hex to .bin converter afterward) or translates the hex into binary and saves that on the fly.
@mild elk https://github.com/wa1tnr/amrforth-v6_4-linux uses serial bootloader
I'm away from my computer just handheld
on arduino.cc they say that you can power an arduino with 9 to 12V adapter... can i power it with 5V 3A adapter?
@elder hare I don't know offhand, but usually you need a little headroom above the chip's supply voltage.
Which target board?
Arduino Mega 2560
What is the GPIO voltage range on that one? (It's not quite a new design iirc)
6.5 volts
Looks like you could feed 5VDC to Pin 1 of the 36 pin header (18x2). Not sure on that.
Also Pins 2 and 5 on one of the 8-pin headers
Those locations seem to feed Pin 2 and Pin 4 of the NCP1117, which is where 5V comes out of it.
So you cannot use the traditional means of powering that one with a 5VDC supply, but you may get away with feeding it 5VDC at those pins mentioned (but don't use the traditional connector at all, then).
The traditional connector might be okay if fed 6.2 volts, but 6.5 volts seems to spec.
A 9V supply gives a lot more headroom, which may be why it is recommended.
I'd probably just run the 5V supply into the USB input
That doesn't seem to work. ;)
ATMEGA16U2 has 'USBVCC' which is distinct.
It also has VCC which may be supplied through the ATMEGA16U, sourced from USBVCC (I don't know).
Is that the idea here?
Fig 2.1 of ATMEGA16U2 datasheet shows an internal 3.3v regulator fed by USBVCC.
Weird, as it should be able to be powered by USB
Yeah I don't get it (at all). ;)
But there doesn't seem to be a supply path from USBVCC to VCC 5V.
(there could be internal to the ATMEGA16U2 .. dunno)
Sounds like you're correct (anyway) @north stream by the sales pitch from Arduino for this target. ;)
The schematic seems to say that's the one used from the USB connector.
@elder hare You should be able to feed 5VDC from your adaptor to the USB jack on the Arduino, no problem. ;)
USBVCC
I have the answer. ;)
USBVcc at T1, below the ATMEGA2560
I was a redshirt on Star Trek, too ;)
@north stream @pine bramble hey happy thanksgiving!
I am giving thanks for you guys helping me a lot the past few weeks 😄
@north stream do you have a suggestion for a sketch to run a HVPP? I've got everything to make the setup, I just can't find a good way to actually do it. I'm running in to a lot of dead ends with the age of things compared to the IDE version and it doesn't help that I'm reprogramming 1284's
I found a couple of projects out there with sketches, but they'd probably have to be adjusted for your case. Unfortunately, I haven't done it that way (I have an ancient STK500 I use for the purpose) so I don't know a lot of the ins and outs.
Aha, I see. Well thanks or getting me on this path, I'm sure it's whats wrong
madbodger, what do you use to make your stk500 do HVPP flashing?
oh... nevermind... those things run off of serial ports haha
Heh, I use avrdude 🙂
@north stream madbodger after many attempts, applying about 10 fixes to the stuff because it's outdated, and feeding it into avrdude manually... I got my HVPP setup working and unbricked the chips. The problem was absolutely the fuses. I really appreciate you suggesting that
Got another question. I have this RFID module. I have it running and it's reading numbers but do I need to format the numbers somehow?
https://www.aliexpress.com/item/32702090149.html
Smarter Shopping, Better Living! Aliexpress.com
'2 53 54 48 48 50 52 57 51 66 50 83 3 '
is a code it's reading
02 is head; 03 is End number
how do I get the 0 in front of there?
@wind drift Are you getting the code as bytes or a string or what? You can do two approaches for leading zeros. One is to simply do the check explicitly: ```c
if (value < 10) {
Serial.print('0');
}
Serial.println(value);
Another approach is to use a print formatter: ```c
char buffer[20];
sprintf(buffer, "%02d", value);
Serial.println(buffer);
@proven mauve Good job working that all out and getting them fixed! Are you going to post your updated code somewhere so someone else in the same situation can use it?
Honestly, I'm reluctant to, it's a pretty hacky job. Had to add an avr folder and empty boards txt to the hardware to get the programmer board to show up in menu, then had to uncomment debug mode and also had to add my chip name into another part of the configurations, and I think that got me far enough that it compiled, then I had to try and flash the bootloader and copy the avr command it kept erroring on and paste it into cmd and edit a bunch of things in it, like adding the com port, deleting a variable that displayed as text instead of an actual value, then added in my flash values instead of the crazy ones it wanted to default, and make it only flash one at a time instead of trying all 3 at once...
@north stream I was just printing them one by one as an int
In that case, either approach I mentioned should work for you.
int r = Rfid.read();
Serial.print(r);
Okay I will give it a try
seems to work
thanks!
If someone ends up interested in updating scratch monkey to work with the newer IDE I would be happy to help, but my knowledge has too many gaps to actually do a clean job of it at the moment
I publish ugly code with expired-context comments, as if that were the planned outcome.
so I have been playing with building my own keybard, and with the discount today I thoucght why not get a feather
has anyone done that recently, I have read in the past of a feather being used
my brain is fried. can i get somebody to look at 12 lines of C, and gimme a hand?
i have a stepper motor with 600 steps (i used a 3:1 gear ratio). just trying to work out how to move the shortest distance to my destination
currPos = 595; nextPos = 5. the result should be +10 steps
math is hard
@vague kettle Looks like you need to check for four different conditions:
- nextPos - currPos > 300: go backward through zero to get to nextPos
- nextPos - currPos > 0 but <= 300: go forward by nextPos - currPos steps
- nextPos - currPos < 0 but > -300: go backward by currPos - nextPos steps
- nextPos - currPos <= -300: go forward by nextPos - currPos + 600 steps
(Doing math in my head... I think in case 1, you go backward by currPos - nextPos + 600 steps, but definitely check me on that.)
that code works in some cases, but currPos=595; nextPos=5; breaks it. result is -590
*the code i posted that is. im working on the stuff you posted
Right, it's less than -300. In my code you'd go forward by 5 - 595 + 600 = 5 + 5 = 10 steps.
Alternatively you could use the modulo operator: delta = (nextPos - currPos) % 600 and then go backward by 600 - delta if delta > 300. It's shorter but maybe also less clear.
thats the way i like it. this seems to work
looks like it works with anything i throw at it... i think?
i think it works. any edge cases i should think of?
5,10 works. 10,5 works. 595, 5 works. 5, 595 works. 0, 299. 299,0. 301,0. 0,301.
i think it works
Should be good to go.
im going with it
azimuth from my home, is 60. it says to move 60 steps. so far so good lol
and im doing that math manually, not checking this website from my code. just using it to confirm my results
60 steps is incorrect, but at least i see the problem, and im getting close
What kind of protection do I need to power an Arduino and motor shield with a 3s lipo (11.1v)?
@grand skiff That should be fine
@dense kiln You can power them both with that supply simply and safely enough. You can connect the supply to either the shield's motor input, or the barrel jack on the Arduino Then install the VIN jumper on the shield to connect the motor supply to Vin, to connect Vin and the motor supply together. This is a popular configuration, which is why the jumper is provided to allow using a shared supply like this. It's described here: https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/powering-motors#if-you-would-like-to-have-a-single-dc-power-supply-for-the-arduino-and-motors-7-4
The motor shield info warns to disconnect the Vin connect jumper in case the supply is over 9V. So I thought about wiring the battery to the barrel jack and to the power pins on the shield. Is this good?
I also thought about getting a voltage booster for 12V, so it never goes below 12V even when the battery discharges. Is this safe? Sorry for bothering you even more
The way I read it, an ordinary 9V battery is insufficient to run it, but 6-12V supplies capable of sufficient current should be fine.
More than 12V would be too much for both the regulator on the Arduino and the motor controller chips on the shield.
If I have a choice, I normally prefer to wire the power supply to the shield instead of the Arduino. My thinking is that the shield is the high-current load, so it should have the best connection to power.
Or would it be safer to just forget this weird plan and power the Arduino with a 9V common battery and the motors with the Lipo?
It's probably safer, if not simpler.
Generally not: 11.1V is pretty near the maximum as it is, so unless you need the very last bit of torque/speed and don't mind losing battery life, I'd stick with that.
Guess I won't be using one then. Thank you so much!
@pine bramble just got back here, I lol'd
I have the 3.5” TFT breakout connected to the feather M0. Whenever there is a fluctuation in power the screen turns gray and only rebooting the arduino fixes it.
Any ideas how to get the display to show stuff again without restarting the M0? Thanks!
@north stream thanks!
Is there anyone that could please help me adding the lines to inizialize and use the adafruit adxl345 acceleromer in my code?
#include <GY6050.h>
#include <Wire.h>
#include <VarSpeedServo.h>
#define angle1 20
#define angle2 90
#define Sensor_BL A0
#define Sensor_BR A1
VarSpeedServo servo1;
GY6050 gyro1(0x68);
GY6050 gyro2(0x69);
int X = 0;
int Y = 0;
int y1_axis = 0;
int y2_axis = 0;
int sensorBL;
int sensorBR;
int speed = 0;
int angle = 0;
int prev_y1_axis = 0;
int y1_hold = 0;
unsigned long timer;
int start=1;
void setup() {
Serial.begin(9600);
Wire.begin();
gyro1.initialisation();
gyro2.initialisation();
delay(100);
servo1.attach(8);
servo1.write(90);
}
void loop() {
y1_axis = gyro1.refresh('A', 'Y');
y2_axis = gyro2.refresh('A', 'Y');
sensorBL = analogRead(Sensor_BL);
sensorBR = analogRead(Sensor_BR);
```cpp
int main(void) {
statement();
}
```
;)
This is also usefull