Er, no - allInputsOn will only execute when it is called: here, in loop after updateInputs is called. The processor only does one thing at a time - and only as you tell it ... so just because we wrote it as a function - this isn't like an algebra function which is continuously defined... When allInputsOn is called (in the if statement in loop) - then, at that moment, it will compute - looking at that moment what we know about the inputs.
#help-with-arduino
1 messages ยท Page 85 of 1
i am starting to grasp most of the code, thank you for all the effort! as always, it's filled with information
i didn't know you could do a lot of extremely handy things shown here
do you by any chance have any online courses or something similar?
no.. just helping folks here! i should start a coding dojo!
i mean, you would make a great professor!
thank you!
2 questions: at the if in the void loop, does it automatically say "if (allInputsOn==true?)", and in bool allInputsOn, why does the calculation for windowsStart work?
- The
voidinvoid loop()means "this function doesn't return anything"... so we refer to that function asloop() if (x)is exactly the same asif ((x) == true)There is never a reason to explicitly check for equality totrue: Something is equal (==) totrueif and only if it is equivalent totrue.ifdoesn't need a test operator (like==or<) -- it just needs something that istrueorfalse(or something that can be converted to them).
Now, think about the condition you are testing: "All the leds shall be considered to have flashed on right now if they each flashed on within the last x milliseconds."
and to see if i understoond, in allInputsOn, the if asks if all elements have been seen to be on, and if the on time are not older than 100 ms?
There are two conditions "have flashed on" and "within the last x ms" and these must hold true for all inputs ----- so if either condition is false for any input, then the whole thing is false. Hence the if in allInputsOn tests two things "did it not flash?" (!seenOn[i]) - and "was the on time older than x ms" (onTime[i] <= windowStart) -----
---- SO, windowStart needs to be "x ms ago" --- or, as computed now - onWindowWidth.
and last question, if they did flash, we call the clearInputs function, but if they don't flash, what resets them?
also, thanks again for all this, truly, after only a couple minutes all i can say is "of course this is the solution, how could someone not see that this is the solution".
Well.. that raises the question about what "all flash" means! for example, consider this flashing pattern for a 3-LED system:
LED1 --- 60ms -- LED2 ---50ms -- LED3 --40ms -- LED1 -- 10ms -- LED2
When LED3 flashes --- nothing has cleared our knowledge of LED1 going off... but so far in the past it doesn't matter.... but that's okay. It did flash in the past (seen[0] will be true) but it's onTime[0] will be older than the window..... Later when it flashes on again - it will be updated and things will be okay
and only then it will be completed
Actually - the clearInputs() call in the if is optional!! It depends on if you want to consider "reflashing"... or if all must "flash again"
this is so much fun
Notice that there is a "sliding window" effect here: In that sequence ... 1-2-3 wasn't a flash (1 was too old)--- but that same 2 & 3 flashes were part of a 2-3-1 which was a flash.
The hanging unanswered question from the problem definition is: Is it still an "all on flash" with 3-1-2? Or once we say we see an all on flash "2-3-1" --- do we clear everything and now need to see each led flash anew?
and won't a weird input, say, for some reason a light flashes two times, fill the onTime arrary?
If they answer is "yes, anew" - then leave the clearInputs() call in... If no, it's an all flash as long as they are within the criteria, the take it out!
also yes, great point
So much of programming isn't really about getting your code right ... it is about really understanding the problem you are trying compute.
this did seem obvious at first, but with every new challange it becomes more and more apparent
such a fitting name, proframming "language". you basically spit out your logic to a computer in a way it understand you
the better your logic the cleaner the code
thanks proffesor! time really does fly with such great lessons, it's 7 am here already
Well good morning! Time to brew some coffee and get coding!
It is 9pm here... time to settle in with the crossword puzzle.... (well, after perhaps fixing one more bug in my code.....)
Good morning indeed professor! As for me, it's time to rest my eyes a little bit, it's been a long but productive day.
Have a nice day everyone! Thanks again!
Hi I want to know if a generic arduino compatible camera can be used for recording video and that if it can transmit the video to another display
Generally, not really. Arduino-compatible cameras tend to be for low-res snapshots rather than video, since their interfaces have been simplified. If you want to tackle video, you're better off going with something like a Raspberry Pi.
ESP32 but its very poor quality
is there a list of scancodes that the adafruit keypad library supports?
or should i be using another library?
in addition to normal numbers and operations, i need ce, mc, mr, m-, and m+
square root would also be nice
Even if Keycode doesn't have an entry, you can just use the key code number assigned too the functions with the adafruit_hid.keyboard functions.
It's defined by USB. See the list in chapter 10 here https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf#page=53
P. 58 has what you are looking for
i understand that part, what i'm asking about are the """keycodes""" that the library uses, which are formatted/look like this
i'm wondering if there is a list of these
sorry if i'm not making sense
Those aren't keycodes. Those are characters.
i understand
but these represent scancodes, and i need to find what i should put here to represent a scancode for mc, m+, m-, etc
some calculator specific ones
i should add that these aren't going to a computer, they're just controlling a super basic calculator on a 32u4 that's driving an oled over i2c
so maybe i can just use some placeholders?
What library call are you using? Again those aren't scancodes
i know they aren't scancodes, i don't know what else to call them lel
i believe this is the adafruit_keypad library
OH, gotcha... This has nothing to do with USB or scan codes! In that library you just give it a map of positions to char and it tells about keys in terms of the values you assign. You can assign anything, but it must fit in char
So, ASCII characters only, which doesn't have things like MC or CE.
ahah, i see it now scrolling through the rest of the code
makes much more sense now, thank you
But.. just use any spare characters you want.
i thought that those somehow corresponded to actual scancodes somewhere/somehow...if you can't tell i have zero experience with this haha
alright, thank you, makes much more sense now
Well, I'm at this code rev: https://github.com/MegaMute/arduinoProMicro5V/blob/main/MegaMute.ino
and my digital pins are not registering any state changes at all. I'm fairly certain I'm connected to the correct physical pins as they are numbered the same?
Any ideas why my ISR might not be firing?
Sanity check: do you periodically see the output on the Serial lines?
yep ๐
{"c"=0,"t"=35503,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
{"c"=0,"t"=36003,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
{"c"=0,"t"=36503,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
{"c"=0,"t"=37003,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
{"c"=0,"t"=37504,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
{"c"=0,"t"=38004,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
{"c"=0,"t"=38504,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
{"c"=0,"t"=39004,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
{"c"=0,"t"=39504,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
{"c"=0,"t"=40004,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
{"c"=0,"t"=40504,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
{"c"=0,"t"=41004,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
{"c"=0,"t"=41504,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
okay - good...
c should be 1 for any change caused pulse.. and the corresponding v= should b 1 and t > 0
an aside - your volatile annotations aren't needed here --- you aren't trying to keep the compiler from reordering things.
I had them since they could be changed inside an isr
so the compiler wouldnt optimize out.
c will always be 0 --- you set sendData = false two lines above.
ah! good catch on that ๐
i just rearranged that too...
FWIW my code on github is being cut/pasted from arduino at the moment since their ide sucks and im just updating the repo casually ๐
i just updated it again ๐
the compiler won't optimize accesses or writes to them - they are global. In this context volatile only means that it won't reorder them within a function. See https://en.cppreference.com/w/cpp/language/cv for details... but yes, this isn't your issue.
excellent. I figured I was playing it safe there.
Its been a few years since i have done microcontroller code on the daily.
Okay - SO - if "c"=0 all the time, then we know that isrDigitalPinChange is never getting called.
i did catch one at Pon
but no associated changes.
{"c"=0,"t"=120004,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
{"c"=1,"t"=1,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
{"c"=0,"t"=501,"s"=[{"k"=0,"v"=0,"t"=0},{"k"=1,"v"=0,"t"=0},{"k"=2,"v"=0,"t"=0},{"k"=3,"v"=0,"t"=0}]}
after kicking reset
which board is this?
arduino pro micro 5v from sparkfun
i have a 5v opto isolated logic shifter connected directly to the numbered pins in the code.
the pin numbers are what is printed on the silk and matches the diagram i saw
as far as i could tell.
the +5 of the opto circuits is from the arduino, as is gnd.
associated leds on the opto boards are toggling as appropriate.
i do wonder if there's not enough resistance on the ports.
but i think that's not it. suspect something in my setup. I've seen it toggle when using other pins, but am committed to not changing pins because it doesnt look like i should have to and i want to otherwise understand why i am changing and not just randomly testing for pins that seem to behave.
appreciate your time by the way ๐
From what I can tell, only pins 0, 1, 2, 3, & 7 can interrupt
https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide#hardware-overview-pro-micro - search the page for interrupts
Arudino's own docs always seem incomplete to me.
Now -- since you are sending JSON on any change.... I'm guessing that you don't need to use interrupts at all here.
Just call isrDigitalPinChange() at the top of loop()... and move the sendData = true; line into the if
no - 0 (digital) is RX on the upper left
ok. thought so.
(Arduino pin numbering.... is a special snowflake!)
my ideal was to use interrupts and not poll to reduce power/heat?
but what pins do you think I should use?
if i have a bluetooth serial needed
Ah - right - though at the moment nothing here will save any more power over what I propose.
Your loop() is still running full out as fast as possible.
oh and i do see 1 and 0 are swapped as you indicated.
goofball indeed.
i didnt even catch that. my brain juts skipped it.
so im basically stuck with polling since the interrupt pins are wasted/useless/insufficient in number.
?
AND --- without diving deeper, I don't know that your interrupt scheme can save any power, as you need to have interrupts that can bring the unit out of sleep.... and usually not all interrupts can do that.
Also if you are communicating via BlueTooth.... can you have the device sleep... won't it drop connection?
its a separate module ๐
but i mainly worried about heating the cpu unnecessarily
if i wont cook it hot leaving it doing that, then yeah forget it!
ok i had one run hot, but i think that was a source/sink issue before I had the optos.
long live teensy ๐ฆ
it seems to have baked itself
and it didnt even have fun doing it
These things aren't like desktop CPUs that will happily burn themselves up if the OS's temperature throttling doesn't kick in quickly enough!
once upon of time, every line being sent through a particular gate... people were checking their code against the internal gate logic and computing the power draw per clock cycle.
now.. meh... we're better at hardware and power is free ๐
We've all burned out a few processors.... price of getting our hands dirty with soldering and electronics! ๐ I had my last Feather M0 fry two days before a music show I was doing with it... because I accidentally wired +12V to an input pin....
erps.. yeah. I had a whole twitter thread about the Genie/Pixie Liberation Alliance
once they are liberated, the equipment refuses to perform for you any longer.
...had to canabalize another project to have a board to work with in time.
i am on 1 of 2 available pro micros now as a result ๐
my first iteration i lost time because i had an insufficient power supply that cooked itself at full draw and i thought i had an issue and spent days re-checking wires before becoming confident again.. then cooked the teensy promptly before adding optos...
now with optos and the 2 pro micros.. they seem to be behaving- except for me not realizing the whole lack of interrupts thing.. i "grew up" on analog devices micros.
they seemed to have more interrupt pins.
maybe i have rose colored glasses.
actually my first micro was a parallax pbasic stamp back in the early 90's i think
Am I clear to ask my question or are you guys still talking?
#include <Wire.h>
#define pA1 10
#define pA2 9
#define pB1 8
#define pB2 7
char state = 'o';
void setup() {
Wire.begin(0x8);
Wire.onReceive(receiveEvent);
pinMode(pA1, OUTPUT);
pinMode(pA2, OUTPUT);
pinMode(pB1, OUTPUT);
pinMode(pB2, OUTPUT);
AllOff();
}
void loop() {
if (state == 'o'){
AllOff();
} else if (state == 'f') {
digitalWrite(pA1, HIGH);
digitalWrite(pA2, LOW);
digitalWrite(pB1, HIGH);
digitalWrite(pB2, LOW);
} else if (state == 'r') {
delay(100);
digitalWrite(pA1, LOW);
digitalWrite(pA2, HIGH);
digitalWrite(pB1, LOW);
digitalWrite(pB2, HIGH);
}
}
void receiveEvent(int stuff) {
while (Wire.available()) {
char c = Wire.read();
if (c == 0x0) state = 'o';
else if (c == 0x1) state = 'r';
else if (c == 0x2) state = 'f';
else state = 'o';
}
}
void AllOff() {
digitalWrite(pA1, LOW);
digitalWrite(pA2, LOW);
digitalWrite(pB1, LOW);
digitalWrite(pB2, LOW);
}
Does anyone have an idea why this code would be failing? If I send it "0x2" (Forward) then send it "0x1" (Reverse) it will stop in place until I sent it "0x1" (Reverse) again.
(The codes are being sent from a Raspberry Pi through I2c btw)
(Also, pins 10-7 are connected to the input of a l298n motor controller)
Is the Arduino library found here: https://github.com/adafruit/arduino-CAN the adafruit recommended lib for can-bus?
@pale shell what are you expecting the pins to do while the state is 'r'?
Set the motor controller to drive the motor backwards
It just looks like loop will write the same values again and again
no no - I mean that after a 0x01 event, state will be 'r' and loop will then write LOW into pA1 forever... again and again.... This means that pin 10 will just go low and stay there... Similarly for the other pins.
yes - there is no reason to keep setting them
BUT - what pins do you have the L298n's enable signals connected to?
You are setting the direction... but where do you turn the motors on?
10, 9, 8, 7
that's to inputs 1, 2, 3, 4.
Yes
what is connected to ENA and ENB?
Nothing, I have the jumpers attached
so the motors are just going to run full speed... all the time ... that is your intention, right?
Yes
k
If you have the Serial console available, you could put Serial.println(state); at the top of loop--- so you'll first prove to yourself that your commands are correctly getting to loop()
Yeah that's how I was originally going to debug it but the raspberry pi's serial is at a different voltage, so I can't. I don't think you can serial through the usb cable on an arduino nano, can you?
dunno - about the nano....
Welllll... do you have a spare LED and resistor? You can use that to debug!!
I'm sure that I do somewhere. What I was doing to test if the state was going through was blinking the builtin LED x times for each state (1 for off, 2 for forward, etc.)
that's good, too! So - you are certain that your commands are causing the proper state value to be seen in loop
yup
next step is to see if pin 7 is doing what you expect: Either a multimeter or the LED+Resistor
the code is pretty straight forward
Lemme grab my multimeter quickly
It seems I've lost my multimeter
I'll grab an led then
and a resistor!
test the other pins....
I disconnected one set of motor wires and now the other one is working perfectly
I'll test the other side too
That's... really weird. If I unplug one motor and use the LED the LED lights up at the right times and the other motor switches from forward to reverse perfectly
but if they're both in I have to send the command twice if it's already running
that makes little sense --- since sending the same command twice in a row shouldn't change the state of the output pins at all
That'ss why I'm confused
(aside - why is there a delay(100) in your reverse code?)
Okay - now we need someone who has experience with this motor controller - since I don't think the issue is code...
oh - wait.....
I hda the delay there to test if I was just switching things too fast, I have it out now, guess I didn't notice I left it in this
Aand it's a power issue
Once I connected the arduino and the raspberry pi to different power sources everything worked as expected
I guess that the raspberry pi's 5v output isn't stable enough
were you trying to power the motors from the 5v from the pi? I imagine that wouldn't work....
pi doesn't have all that much to give I think
Yes the motors are powered from the pi, the arduino was as well
The motors take a total of about 2-3 volts together so that was clear, guess it left too little for the arduino though
how do i differentiate analog pins from digital in my code? in this case, they are both "pin 5" according to the pinout i'm using, but i have my input on analong pin 5 (using it as a digital pin)
oops sorry just saw your message. Based on what I've seen you access analog pins through names like "A0" or "A1"
So - pins: Here's the skinny: If you look at a pin out diagram for any Arduino board, you'll see that there are digital pin numbers (usually just a bare integer), and analog pin names (A0, A1, etc...)... There will often be two or more names for the same pin. For example, on a nano, pin 14 is also A0.
In your code, you should use the appropriate name:
digitalRead(14) // if reading the pin as a digital input
analogRead(A0) // if reading the pin as an analog input
However - here's the dirty secret: A0 is just a constant of.... 14 for the Nano
The reason there are two different names is because "the first analog input" is shared with different digital pins on different boards. So, your code is both more clear, and more portable, if you use A0 for the analog reads... because that'll map to some analog input pin on all boards.
If you did analogRead(14) it would work on the nano... but not make any sense on other boards.
Hey another quick question: would this https://www.amazon.com/AUKEY-10000mAh-Portable-Delivery-Nintendo/dp/B079Z4RHZZ?tag=p00935-20&ascsubtag=04TK6Xolo3rr08ouRcKNdQ0 be able to safely power an arduino nano and a raspberry pi with 2 1.5v motors for like an hour or so?
unclear - you need to know how much power (amps) you are drawing. I believe that RPis like to have a little more amps than the spec allows... if you look at your RPi power adapter - it probably says 2.5A at 5V. You'll notice that must USB ports are only 0.5A @ 5V... and can deliver higher under some circumstances. ...
how do i access the value of like 100 in first one
like colourValues[0][0] does nothing
That unit says 2.4A... but who knows if it will for a Pi!
Hmm I'll have to look into that
@pale shell @obtuse spruce not sure if this changes your answer, but i'm just listing pins for a key matrix as byte rowPins[ROWS] = {9,8,7,6}; //Rows 0 to 5 byte colPins[COLS]= {5,4,3,2}; //Columns 0 to 4 (placeholder pin numbers)
would i still use, say, a0 for an analog pin?
@unborn pumice - what do you mean "does nothing"? colourValues[0][0] references the first value... Serial.println(colourValues[0][0]); should, for example, print 100
whoops
Serial.println(int(colourValues[0][0]));
also, this is sufficient for a keymap, correct? i have to change pin numbers (and some of the oled stuff is for later on) ```#include <Adafruit_Keypad.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1305.h>
// Used for I2C or SPI
#define OLED_RESET 9
// I2C
Adafruit_SSD1305 display(128, 32, &Wire, OLED_RESET);
const byte ROWS= 6; //number of rows on the keypad
const byte COLS= 5; //number of columns on the keypad
char keys[ROWS][COLS] = {
{'7', '8', '9', '-', 'C'},
{'%', 'M', ' ', '+', 'R'},
{'=', 'P', '/', '*', ' '},
{' ', 'E', ' ', 'A', ' '},
{' ', '4', '5', '6', '.'},
};
//Code that shows the the keypad connections to the arduino terminals
byte rowPins[ROWS] = {9,8,7,6}; //Rows 0 to 5
byte colPins[COLS]= {5,4,3,2}; //Columns 0 to 4
//initialize an instance of class NewKeypad
Adafruit_Keypad customKeypad = Adafruit_Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);```
just realised i had it as char for some reason
also my serial.print only prints two letters from
Serial.print("test"); prints out te
As mzero said, and what I didn't know previously, is that A0 just maps to a pin that is analog, and as he said, for the nano it'd map to pin 14, but it'd obviously differ from arduino model to another. So depending on what arduino you have A0 would reference Analog 0 on the pinout/board
when called from interupt
i have a 32u4 so i'll glance at a few other pinouts, the one i'm using just lists pins as "digital pin x" or "analog pin y"
@unborn pumice - don't call Serial.print inside an interrupt!
Just curious, what happens if you call Serial.print in an interrupt?
depends on what interrupt - and what it was doing before the interrupt was called.... If you are interrupting another Serial.print in progress... there is nothing in the code for Serial that ensures the two calls won't stomp on eachother!
Ah
(note - some board core libraries could have protection for some Serial devices... but I don't know of any.)
It seems that the raspberry pi is working successfully when powered off my laptop usb ports so that may be promising
this literally makes no sense
supposed to make the rgb light go red
but it goes yellow from a 255,0,0 write
first - char colourValues[][3] = { ... } -- the arrays are 3 elements long --- but that won't be your problem
So - RGBarray is an array of three pins - which your expecting PWM output to? and you've set them to output.... yes?
Have a QT STemma LED display and wanted to prototype with it, so I figured I'd hook it up to my QTPy. QTPy "Blink" code runs, but the LED doesn't blink. Serial println statements work, just no blink. Figured I'd just keep going and deal with that oddness later. Hooked up the display and dropped in the example code and no joy. Is there something unique with a QTPy that my normal Feather/M0/Uno experience needs to know about? Can I just assume it's a tiny arduino engine for simple things? Or is the display too much memory/power needs for the QTPy?
Also, you can cut-n-paste your code nicely by putting the whole thing between triple-back-ticks like this:
```C++
int colourSelect = 0;
```
yeah it was acc my wiring overlapping
also how do you read a button to see if it was pressed
like digital read == HIGH does nothing
neither does changing it to 1
how do you have the button wired?
between the pin and GND? Then you need to have the line pulled up high: pinMode(somePin, INPUT_PULLUP)
between the pin and +V? Then you need to have the line pulled down: pinMode(somePin, INPUT_PULLDOWN)
In the first case a read of LOW means pressed... in the second HIGH means pressed.
You read with digitalRead(somePin)
Now -- if this is really a button, be aware that it will exhibit "bounce" -- meaning when you press the button, it will register pressed/unpressed/pressed/unpressed a few times before just staying pressed.
well - do you have an external pull-up or pull-down resistor?
nah
and one end of the swtich is connected to the pin.... what is the other end of the switch connected to?
(this determines if you need pullup or pulldown)
its literally just connected to a digital pin then grounded
so the other end is GND - fine - then you need a INPUT_PULLUP
yeah i changed now
Think of it this way: When the switch is open, the pin is connected to +V via the "pull up" resistor - since there is no other connection to the pin, the pin "sees" +V. When the switch is closed, the pin is connected to GND through the switch and no resistor ... the "pin" sees GND because the connection to GND has way less (infinitely less!) resistance then the path to +V.
Hey all, I'm trying to hook a neotrellis up to an arduino micro...
i have the libraries installed
and have wired it per the instructions,
but nothing happens.
any ideas? I've confirmed my wiring is all correct.
welp... disregard. Looks like I have a bad board.
somehow there's a short in the board.
can anyone help me figure out the best way to display the year i have a 7 segment clock display but no where online has a 14pin diagram that tells me what each pin is all i an find is a 12 pin tutorials i dont have the backpack for the display so i have to wire each pin separately which is not a problem i have a mcp chip to run the display but if there is another way please help i do have a rtc to run for the year and time and day but im looking to show just the year and i want it to change the display for each new year
Im trying to figure out how to include a code that allows my momentary switch to remember where it is in the light state, currently it turns the lights on and off and switches between but its abit fidgety im not sure where im going wrong :/ would anybody be able to assist?
https://gist.github.com/AmazingAmatsu/dec9874b86ce4647e7cfbf10baf4e2df if anybody would like to assist i can post my sample code also
Put some delay in the while loop
you mean the loop() portion right?
The while loop in the if in the void loop
im abit stupid but im guessing this part
yes
im having issues with it but ill have to attempt this again as the port busy errors D:
Anyone have any experience with PlatformIO? I've been using this instead of the arduino env -- when I build -- it says its using 26404 bytes from 28672 bytes (leonardo) -- however when I do the project inspect from PIO -- it tells me 37.8KB (more than leonardo has) -- any ideas on why the mismatch?
Try doing this with a minimal sketch (empty setup, emptyloop) --- and see if there is a difference. Possibilities could be the optimization flags used, the version of the compiler, and the core. If you want to optimize without increasing program size, use -Os .
Also be sure you are compiling with -fdata-sections -ffunction-sections so that the compiler can remove bits of libraries that aren't being used.
Thanks Iโll try those recommendations
What would cause the voltage regulator on my arduino nano to get very hot while powered over USB, but not when powered through Vin (6v)?
The atmel chip seems to get warm as well. It functions perfectly fine both over USB and Vin.
I'm not powering it by both at the same time.
Hmm, is it a 3.3V Nano or a 5V one?
Im not sure. Digital pins output 5v, if that tells you
It only is plugged in USB for a few seconds at a time to upload code, so I guess it's not a big deal. Just odd.
Agreed.
You can use analog pins at digital outputs, right? I'm trying to use it with the liquidcrystal library but it isnt working. Using digital pins works, so nothing wrong with the LCD, but using 'A7' and 'A6' as my RS and EN pins results in nothing on the display.
Hm. Apparently A6 and A7 are the only ones you cannot do this with on the nano according to https://forum.arduino.cc/index.php?topic=248355.0. That's unfortunate. Time to break out the soldering iron again
Yep. Working fine with A0 and A1.
Hello all, I am having an i2c issue I was hoping someone could help me out with. I already asked for help here with a different issue and got some great feedback!
Here is my issue: I am sending data over i2c from a Adafruit M4 feather to a nano. This works fine until I try to update an OLED display from the nano. (It worked fine prior to this issue)
OLED display uses the same i2c bus as used for communication between M4 and nano?
Yes
most likely the problem is m4 and nano competing for control of the bus - each of them trying to be master
I2C bus can have only one master device (but a lot of slave devices)
It gets weirder, I am putting code and logs on github, standby
Here is the code"
And here is the serial output:
if the display is set to update after i2c data is received (line 49 is uncommented), the data previously received doesn't receive correctly
but the "display.display();" doesn't happen until after the data is received and displayed!
displayed via serial, I mean
This looks wrong: byte received_data[] = {};. You need to actually specify an array size in order to reserve some memory for the data, otherwise you'll be writing bytes on top of some other variable.
this (https://www.kultogbillig.no/ESP32-Development-Board-WiFi-Bluetooth-Ultra-Low-Power-Consumption-Dual-Cores-ESP-32-ESP-32S-Board?search=ESP32) is where i used to order my ESP32 but they are out of stock and having some "problems" with the provider of these sooo i need to look at alternatives!
Having a hard time to select which one from here
https://www.digikey.no/products/no/rf-if-and-rfid/rf-evaluation-and-development-kits-boards/859?FV=-8|859&quantity=0&ColumnSort=0&page=1&stock=1&k=ESP32-DEVKITC&pageSize=25&pkeyword=ESP32-DEVKITC
any help would be awsome!
RF/IF og RFID โ RF-evaluering og -utviklingssett, kort er pรฅ lager hos DigiKey. Bestill nรฅ! RF/IF og RFID sendes samme dag
This makes sense, I fixed it, but unfortunately didn't solve the issue
You're still seeing the crash?
yes
I'll have to defer to someone else who's more of an expert on the Arduino I2C library. Two things that are possibly questionable is performing Serial output in a byte-received event, as that might be happening in an interrupt, and having both master (to the display) and slave (from the Feather) I2C functionality on the same Wire interface, which may not be fully supported, as usually a device is either one or the other.
okay, thanks for your help. I will look into those
hey quick question the DC barrel on Arduino Uno the inner part is the +5V right?
Right, be careful there are jacks that have it the other way for some stupid reason
Or, that is the positive input, it can take 5 to whatever your specific model is rated for
it all worked out
I did use the multimeter to be extra sure
I am feeding 7.5V hope the regulator will handle the extra 2.5V
yep I'll let it run for some time to see if I have heat problems
You will if you are drawing a fair amount of current, its a linear regulator, so extra energy is just wasted as heat
yep I don't think I am drawing that much.. I usually use the 1 night running test :p
I have a question, when you finish a project, do you leave your microcontroller for instance Arduino uno. with that project and by a new one, or are there smaller boards that achieve the same goal that you transfer the code to to manage the machine
? Do you need the project to continue to run? If so - what hardware does it need? If a smaller / different board will suffice, then sure, move it there and free up the Uno....
That said... I have multiple Adafruit Feather M0 / M4 devices - and a few Circuit Python Expresses.... all of these are SAMD based, so more powerful, more memory - and pretty much the same or cheaper than the Uno. I also have a few even cheaper SAMD device (itsybitsy) -- I move projects around them all the time - though there are some that are "doing their thing" and I just leave them.
Depending on how few GPIO lines you need, and other connectivity options - you can get smaller boards for under $10.
I usually develop on the target hardware.
And since Arduinos are not very expensive I think it is best to leave it as part of the project.
Hello, how do you turn off a led strip. Knowing that this led strip uses adfruit libraries
Or to refresh the led strip
Is it a neopixel strip or just LEDs
Yes is a neopixel strip
OK thank you
Yes is arduino
my mistake - forgot which channel I was in.
OK
you should be able to do strip.fill(0); strip.show();
I'm going to try
His function
Hey all I am a complete newbie when it comes to arduino stuff and I am trying to wire this OLED board (https://www.digikey.com/en/products/detail/newhaven-display-intl/NHD-0420CW-AG3/5022950?s=N4IgTCBcDaIHIAkAiBaADAFjGgwgdRQEEBxAZhAF0BfIA) to an arduino mega so I can write text that appears on the OLED board. I have figured out what pins are ground and power on the board from it's data sheet in all honesty I don't know what to do with the other pins so some help here would mean a lot
The interface is just typical LCD1602 interface
Thank you!
Anyone in the WA area have a row of .1 female headers i could buy/get like now? ๐
i have some amazon tomorrow... but i am impatient with an idea burning a hole in my brain.
does Adafruit do same day delivery?
I tried. Tomorrow was as good as i could do. Its a pandemic and I'm not curing cancer ๐
mostly kidding about the same day thing anyway.
its also 3:30p PT
I'm in way over my head - trying to switch my project from CircuitPython to Arduino/C because I've been running into out-of-memory issues. I'm using a MatrixPortal and have managed to get the Protomatter examples working but my next step is querying data via a web API call (it returns JSON) and I'm not sure where to look for that.
Oh.. ArduinoHttpClient > SimpleHttpExample looks appropriate... Carry on!
@remote viper AdurinoJson is a library for parsing json. But it can be a bit heavy on the memory too.
@wraith current I saw that one too and have installed it, thanks. We'll see how it goes. I wasn't far off with CP so I should be able to pull this off.
... If I can recall my C from ~30 years ago ๐
The JSON library is indeed a memory hog
JSON in general is, its great for humans to read but not much else
go go protobuf and gRPC
at them moment JSON is more something that makes your system easy to integrate
In the scope of a single endpoint sure
what do you mean?
If you need to maintatin a massive API, it is a gosh darn nightmare after you have multiple people work on it, different clients, etc. Its so much nicer imo to have a defined protobuffer so that any client which can use that version of the api, as long as they used the proto file, will for sure work. It just becomes way eaiser to prevent logical errors over time
oh ok... you mean YEY for protobuffer and JSON is actual only cool if you just have one endpoint to connect to the world (that already have a bunch of services ready to parse JSON)
so it is not really cool... just something that will be easier to integrate with min effort for a single end point
if it is actually JSON where you can't have white spaces or line returns .. it starts to get difficult to read it and you will put it on some formatter and at that point you could do something similar to the protobuffer binary
Also, if you handle say 1 million requests, the amount of overhead is pretty large
I fully agree with you btw. ๐
I did use it on a recent project because I just wanted to send something using MQTT to be consumed by node-RED that inserts that is a influx DB and can be displayed with Grafana
And the fact that with zero knowledge I got that to work in 30 min was pretty cool
Nice, Ive been eyeing Capt'n Proto recently, the promise based rpc looks really awesome. And yeah, I really like how I can just compile a quick proto file, and just put the output in any project quickly
Espesially for embedded devices, you could really cut down the time for a bunch of HTTP requests
Therefore, more battery
At the job we are starting to think on building some embedded services based on protobuffers and providing a gRPC API
however we are all electrical engineers that can code low level stuff in C pretty easily but we get a bit scared when we get higher in the stack :p
Sure, you might like rust, systems programming language, fast as C, guaranteed memory saftey at compiled time, and when its time to make your services its producive enough to write high level appliactions if you choose to
I've heard about, also have been working with golang..
Golang is awesome too, love em both
But I dont like a garbage collector in my kernel ๐
Idk about you
we were thinking on maintaining all the low level bits in C and have these services that feed data to external end points written in golang or other higher level language
Ah, well if you ever get the chance to work with rust, I have no more reasons to keep using C. Its just as fast, the binaries are the same size, its more productive, and I can give it to a monion without fear of them bringing all my customers offline with another stupid memory bug
Compild a blinky for a STM32F4 and it was the same size as the c version
business point of view it is easier to get people to work on low level software and people that are good on higher level stuff... so having those things separated with clean interfaces maybe be good
Certainly, but I also wrote a library for my companies application layer protocol in rust, it took me under an hour to get github CI to auto compile binaries for bare metal ARMv7, linux ARMv7 soft float, linux ARMv7 hard float, linux x86, ARMv7 Android ARM, x86 Andriod, iOS ARMv8, iOS ARMv8, iOS x86, Widnows x86, MacOS x86, and MacOS ARMv8
All the same code base, not a difference
Does this look like a sane way to build a URL? locid and key are char and come from a secrets.h file.
const char kPath[] = "/data/2.5/weather?id=";
strcpy(kPath, locid);
strcpy(kPath, "&appid=");
strcpy(kPath, key);
strcpy(kPath, "&units=imperial");
Talk about business point of view productive
That wont quite work, close though
strcpy replaces all contents, to append to that, you want to use strcat
So the first strcpy is right, but not the last three
and yes the general idea is sane
oh, got ya. okay. thanks!
You could also shorten this with sprintf
I miss Python already, lol.
Well, i'm honestly not a fan either. I most "code" in PowerShell. But, well... I'm working on embedded stuff ๐
Hey let's just be glad we're not using VBA
Fair enough
strcpy replaces all content? include what the char was defined with?
Right, so you want all strcat my bad
Or strncat if you dont like living in the danger zone
Hence the danger zone part XD
I'm sure there is a 10k word thesis on the difference between the two, of course.
Strncat also takes a size variable, if you feel like having code look like its not from the 80s
Yeah, I see the difference now. Makes sense
DESCRIPTION
The strcat() function appends the src string to the dest string, overwriting the terminating null byte ('\0') at the end of dest, and then adds a terminating null byte. The
strings may not overlap, and the dest string must have enough space for the result. If dest is not large enough, program behavior is unpredictable; buffer overruns are a faโ
vorite avenue for attacking secure programs.
The strncat() function is similar, except that
* it will use at most n bytes from src; and
* src does not need to be null-terminated if it contains n or more bytes.
As with strcat(), the resulting string in dest is always null-terminated.
Ah, buffer overruns, fun... Yes. Right. I'm dealing with low level languages now ๐
So I always put the size variable as sizeof(buffer)-1
I got a stern look from a prof for calling C low level once. But he taught assembly
Can also do some fancy preprocessing if you dont wanna do the math every time
Hey, my grandma tells me the same about punchcards
ahah
IIRC punchcards are where "patch" comes from. At least that's the trivia I have decided to go with
Huh
like you'd "patch" over punch(es) to make changes to the program
Just one thing you said you were using ArduinoC but Arduino is C++ so you actually have a library to handle strings
I learned FORTRAN on a PDP-11 teletype (I was auditing a college class with my dad - i'm not quite that old)
The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.
If you are coming from Python I think you will have easier time :p
I've got about 20k lines of PowerShell in the repository at work but... well, that's no better than Python, really ๐
What's with the red in this silly Arduino IDE?
You mean orange or do you have a red bar somewhere I dont see?
I mean orange, I suppose
Ah, its just a keyword, someone who made the lib told arduino in a keywords file to highlight it
Its just for easy reading, the arduino ide isnt great
Okay, thanks. It's annoying.
Try platformIO if you dont like it, way better
Yeah, I started to switch to VSCode but haven't gotten there yet.
blah blah missing library path or some nonsence
Aaah, yes... Now I remember now why I'm in management!
interpersonal skills ๐
Why does this work:
String kPath = String("/data/2.5/weather?id=" + locid);
But once I try either this:
kPath.concat("&appid=");
or this:
kPath += "&appid=";
It breaks with the message error: 'kPath' does not name a type
as if that type wasn't defined?
vsCode is telling me "This declaration has no storage class or type specifier"... Wait. declaration
The code was outside of the loop so only declarations work.
does it work in void setup?
That is using string objects, ew
Uses a lot more memory
And is dynamic allocation
@pulsar junco Yes, it does.
And @stuck coral now that I know what was wrong all along with trying to do stuff outside the loop i'm going to try char again.
Lol, okay ๐ come back with any questions
More meaningful than "why do all the examples work but none of my code does?"
What is the smallest microcontroller that is capable of running off of a lipoly or li-ion, recharging said battery, and driving a small color display (240x240 or less). By driving I'm only looking at basically having it show a different picture every 5 seconds, so high fps isn't important. I was looking at the xiao or qt py, but I don't think these can recharge the battery unfortunately, otherwise they'd be perfect! Thanks in advance!
Physically? From adafruit? Probably the trinket m0 with a battery pack or the qt py with a battery pack. @gilded swift your power packs can charge right?
Yuppers
I think the trinket and the qt are similar in size
Qt Py is slightly smaller
plus it's got that nice stemma port
Yep ๐
Rev B for the LiPo power pack will be BMS for better long term battery life
@pulsar junco @gilded swift Thank you for the quick responses! I'm brand new to the world of microcontrollers, sorry I didn't realize that the Qt Py could recharge a battery! I thought it had to have one of those battery connectors to do that. So if I solder the battery to the Qt Py, I should be good to go yeah?
@night jasper not necessarily
it can if you add one of @gilded swift 's battery packs
@night jasper Check out the https://www.adafruit.com/product/4600 paired with the https://www.adafruit.com/product/4741
What a cutie pie! Or is it... a QT Py? This diminutive dev board comes with our favorite lil chip, the SAMD21 (as made famous in our GEMMA M0 and Trinket M0 boards).For a limited time: only ...
This OLED goes out to all the fans who want more pixels! Normally our 128x64 OLEDs are the biggest ones we've stocked that can use I2C. This one is a whopping 128x128 pixels and it even ...
Oak Dev Tech
We love the Adafruit Qt Py. It really is a cutie! And we love it so much we wanted to help you take the board and your projects on the go!
This little backpack not only brings LiPo Battery power to your Qt Py, but also battery charging so you can easily recharge your project.
Dang, my googling is slow - the QTPy has been recommended already ๐
But yes, the STEMMA port is sweet, especially to use a display like that 1.5" OLED
I just ordered another Qt Py to use for testing some new SPI Flash Iโm adding support for in Circuitpython
๐
+1 for open source development!
Also, if you want to use oled on qtpy, you need SPI Flash
$6 is very inexpensive
even in arduino?
Well, maybe not Arduino
@gilded swift @pulsar junco Oh I see now, I'd use the backpack with the Qt Py. That makes more sense to me. Thanks!
Iโm not sure how big the Arduino library is for oleds
np! Happy coding!
can't hurt to get the SPI flash unless you wanted to solder it to a board
could always do a cutout but still
It depends on what youโre doing overall. The samd21e18a is pretty limiting in terms of storage
SPI flash can be a good option either way ๐
@remote viper Is it possible to connect a color oled or tft via that Stemma connection? I haven't seen it done, but if it were possible that would be really convenient!
That OLED works via I2C w/CP
It's grayscale tho ๐ฆ
I was recommending the OLED for power and ease of use.
And yeah, it's greyscale.. I2C is pretty limited when it comes to driving a display - if you want color or more dots SPI is definitely a better choice.
In case you guys were wondering, my ultimate goal is to create a โdigital locketโ as a present for my wife. Basically just a mini digital photoframe on a necklace.
Oh right! That's a cool project
I donโt think there are color oled for i2c
I couldn't find any
All SPI it appears
You just need another QT PY to run your time machine and go back to when B&W was normal
But that makes sense since the data frame for a color oled would be much larger than i2c allows
That's probably the better choice, then.... It's SPI so you'd need to solder it up.
Yeah
Iโm considering making a 6-pin quick SPI standard
Using a 6-pin JST connector
A lot bigger power budget than the OLED tho, but I couldn't say how much.
@gilded swift That would be sweet!
that locket would be a cool project for a PCB to mount the QT + power pack and the display on either side
eInk could be an option if you picked the colors wisely...
And then you'd have battery life for days.
@pulsar junco I've never designed a PCB, but for this project it would be a pretty simple design right? It might be worth me learning how to do!
I was thinking the same thing!
Shouldn't be too bad, #help-with-hw-design can help! It's a full service community around here
Easy e-paper finally comes to your Feather with this Adafruit EInk Feather Friend that's designed to make it a breeze to add anย eInk display. Chances are you've seen one of ...
ooh you could do something with a photodiode and deep sleep, so that it only wakes to display the picture when the locket is open
This would be brilliant! Yeah that was my next step was figuring out how to make the screen turn off and on when opened. I was originally thinking some sort of magnetic switch, but a photodiode might be more practical.
You'd just have to make sure it's truly dark in there, I don't have a ton of experience with them so idk how sensitive they can be
this might be a hefty locket heh
Oh, I'm using a vcnl4040 on this project... It returns a value that you can test so it's easy enough to set sane values.
ahh I guess you could wake on a pin voltage and then quickly read the value and display the image if the value is greater than a certain amount?
This is the thing... Well, the software has changed a bit.
Yeah that's my challenge right now, to fit it all in a locked that doesn't become so large she doesn't want to wear it!
Yeah, and that 'certain amount' is easy enough to figure. The sensor i'm using is proximity and light. You can see 'em both in action there.
I think the QT is a great choice for this
Does it know to not continually switch if it's dark in the room? Super cool!
It switched because of proximity. It dimmed because my hand was between the overhead light and the sensor.
ah right they have an IR LED alongside the diode or something right?
If I can fit one of those in, it will be sweet!
@night jasper Just to confuse you more (lol), the Circuit PlayGround is a VERY cool board... And has a both eInk and TFT add ons. It's not HUGE but it's larger than the QT for sure.
But it's loaded with sensors and such. I recommend it for prototyping regardless ๐
it's got motion, temp and light sensors built in, among other things.
That does look pretty sweet! I think it would be too big for the final project, but definitely useful for prototyping.
It also has the same chip as the qt and trinket m0
they've got one with bluetooth, also.. But yeah, buttons, neopixels, all sorts of handy stuff built in.
There's currently a kickstarter for something called the PocketScreen, but it's a kickstarter that is around a year late in delivery. Which is too bad because it'd be perfect.
Right... So minimal code changes necessary.
Yeah, I'm a super n00b (haven't soldered anything since I was a kid) so it would be fun to practice with it and learn.
@stuck coral Speak to me a bit more about the magic that is strncat()... I seem to have done a "bad thing" and overwritten some memory as the SSID that this is trying to connect to is made up of part of my API key and part of my URL...
You mentioned sizeof(buffer)-1, for example...
i'm defining it, initially as: char kPath[120] = "/data/2.5/weather?id="; and then adding on some things - I know how long they'll be for the most part...
So, in your example there, buffer is the src?
Right, kPath
well, kPath is the dest, src is what is being added
Parameters
dest โ This is pointer to the destination array, which should contain a C string, and should be large enough to contain the concatenated resulting string which includes the additional null-character.
src โ This is the string to be appended.
n โ This is the maximum number of characters to be appended.
.. but in the example they have n as 15, which is the length of src -1...
#include <stdio.h>
#include <string.h>
int main () {
char src[50], dest[50];
strcpy(src, "This is source");
strcpy(dest, "This is destination");
strncat(dest, src, 15);
printf("Final destination string : |%s|", dest);
return(0);
}
Oh lol, than no sorry
strncat(dest, src, sizeof(dest)-1);
You are just telling it what the MAX size the string can be
does strncat reallocate mem then?
No, it just cannot write a char buffer longer than what you enter
or does your dest have to be big enough?
Has to be big enough
ah that's why it's safer correct?
If you want dynamic allocation, use string objects and youll regret it later. Yes
But strncat has functionality for only copying a specific number of characters
That's why it's safer
No, just it cannot have more than n characters in the array
It will return early, and the int it returns will be the same size as your array
Therefore you know you certainly overran it
That is valid if you dont do sizeof()-1 rather just sizeof()
Ah, yes. Undefined if the dest array is not large enough to append the contents of src.
Not undefined, it returns the same size as the array from its return value
Undefined is bad
strcat is undefined that scenario right
Ah, okay, okay.. I see what you're doing there with dest -1
Null character, but if you add a check to see if you overran the buffer, than just use sizeof()
Ensuring that no matter how big src is it's not going to max out dest
Right
well, overflow, technically.
Yep
BUT!!
It's ADDING src to dest so you're not taking into account what's already in there are you?
if(strncat(dest, src, sizeof(dest))>=sizeof(dest)){
// We need a bigger buffer, lets try again and keep it on
the stack
}
The function is
It checks before it writes
It knows how much you have written already because the data has a null appended
Okay... Well, yeah. So I used strcat not strncat first and now my board is upset. it's trying to connect to a WPA SSID consisting of a lot of garbage and appears to have gone non-responsive. I can't upload a new sketch.
What's the recovery protocol when someone like me has "done the dumb"?
What board?
I can get to the MATRIXBOOT by doubleclicking reset
There you go
Matrix Portal
Thats correct
Just reload it.. Okay, makes sense
oh, wow. it still has my circuit python stuff on there, lol
Hehe... Wife said it's time to stop and come to bed.
What she says goes... Adios folks!
Thanks for all the help!
Its on the external flash ๐
Remember its there if you ever need to store some data
hmm... is ~1.2ms per-character about normal for an M0 drawing to a screen using the Adafruit GFX library?
er... not in that the per-character cost isn't the big one. GFX draws to a memory buffer... it is the transfer of the display buffer to the display over i2c or SPI that takes the time.
what display do you have?
it's the Adafruit TFT FeatherWing, the 160x80 ST7735-based one
which has also proven tedious to work with in other ways too, as it doesn't seem to have any sort of buffer, so redrawing big parts of the display ends up being pretty obvious
GFX only deals in 'send the whole thing'
so - first thing I'd look at is what speed is the SPI being run at - and can you up it.
this is the first tft i've worked with though, the SSD1306-based oled displays let you modify everything in a buffer then call a method for that buffer to be displayed all at once
digging through the code, it looks like the library is already running it at 32mhz
"the library" being Adafruit's ST77xx library
hrm... well.... 160x80x16 = ~205kbits = 6.5ms to transfer at 32mHz
perhaps, and a consistent 6.5ms to do a full display update would be ideal if it were an option, but this has no in-memory buffer that gets written in its entirety
er- doesn't GFX have a full in memory display buffer?
so like any call like, say, display.printf("some text here"); gets drawn immediately
strange thing is that yes, it does have one for the SSD1306 displays lol
i guess it's possible that it was a design decision because of the high pixel counts of tfts and low pixel counts of oleds, and memory constraints in microcontrollers....
Ah - well..... if you can afford the memory, use GFXcanvas16 -- draw on that all you want, then draw it in one operation to the display
mathing it up, a full-color buffer would be 25,600 bytes of ram...
quick question about that canvas, i'm pretty sure i seen a GFXcanvas8, would that still work on a 16-bit display?
as it -- will it "expand" when bitblt'd? I'm not sure ... I can go look
yeah, effectively to limit my color options to just 8 bit (and thus only take a bit over 12kb of ram for a buffer), but still let me just dump the whole thing to the display and have it come out right
looks to me that that will work - but be slower. when drawing a RGB pixmap -- it uses on SPI command to set the region and send the data. For the others it sends it pixel by pixel: each taking a command to set the x,y 1x1 region, and then the value.
that's because it has no RGB buffer to send in one go.
though to be honest... seems like it could have an optimized loop for such
hmm, i think i may have to go off into the weeds pretty deep tonight with GFX-related stuff
looking through Adafruit_GFX.h to get an idea about what other stuff might be available aside from just the basic drawing stuff, it looks like it has something called the transaction api
which may let me optimize some parts of my stuff if that does what i think it does
I just looked at ::draw\w*Bitmap functions - and yup - but default in GFX they all end up in writePixel --- and Adafruit_SPITFT implements drawRGBBitmap to send in a chunk... but that's all.
gonna try moving a part of my code over from drawPixel to writePixel and see if the timings on it look any better
if i can get that under 1.2ms for an 8x8 chunk of pixels then i'll just make my own basic font and text stuff lol
and... surrounding the block with startwrite() and endWrite() on your own?
yeah
That is exactly what the drawBitmap functions do - so just use them from your own 8x8 font...
or rather - test using them
hmm, i'll definitely poke around with stuff like that and see if i can get some of that to end up performing better than print/printf/println
You might do well by doing print to a single line buffer, 160x8 greyscale ... that's pretty small - and then drawBitmap that to the screen
alright, 2690us is the number to beat in this quick benchmark lol
1840us, okay so the transaction-related stuff definitely helps
thanks for pointing me in the right direction for some optimizations on this btw
When I set the port and upload my code from the Arduino environment, the board shows up as a "Feather M0 Express" on (for example) COM10 but as soon as it finishes compiling and looking for the board on the port, the board restarts and upon restart it shows up on COM11, and the environment reports it as "Feather M0" (no express) -- and uploads the code successfully. It then restarts the board as expected, which switches back to COM10 and is once again reported as an Express. At which point I can switch the environment to port 10, and start the serial monitor. I've seen this behavior with all of the "express" version boards. I don't do CircuitPython, is there any way to fix/change this behavior?
don't think so. unfortunately that's a windows feature.
I'm trying to make a function to simplify displaying text on an OLED, but whenever I call the function, it says "'onlyLine' was not declared in this scope"
void onlyLine(int x, int y, int fontSize, String text) {
display.clearDisplay();
display.setTextSize(fontSize);
display.setTextColor(SSD1306_WHITE);
display.setCursor(x, y);
display.print(text);
display.display();
}
Here is an example of me calling the function:
onlyLine(4, 4, 1, "Closing chute");
Am I calling it wrong?
I think the issue is more about where are you declaring the function
I am declaring it after the loop function
and call it in the loop function
i am calling it in the loop and setup functions
You need to declare it before setup() and loop()
ok, thankyou
I think that is the issue but try it :p
it was working fine earlier being defined after the loop, but I will give it a try
hey guys, idk if this is the right place to ask this, but im trying to program atmega32Awith usbasp, these are the configurations i set up by following steps on an article, can you tell me what im doing wrong here?
problem: i do not get anything on screen when i click in the Tools-USBasp no upload status no error nothing
Article that i followed
https://circuitdigest.com/microcontroller-projects/how-to-program-avr-microcontroller-atmega16-with-usbasp-programmer-using-atmel-studio
I just got a metro. I am following https://learn.adafruit.com/experimenters-guide-for-metro/windows-setup but the board appears as "silicon labs cp210x usb to uart bridge" instead of "USB Serial Port"
UART = serial port, its the same thing. The important thing is if it shows as a com port.
thank you, kind sir
yep
in this case, the "cp210x" mentioned is the CP2104 chip which sits between the USB connector and the processor on the Metro
from the point of view of your PC, it only sees the CP2104
and your PCs USB talks through the CP2104 to the processor on the Metro, which only has UART serial (i.e. no USB)
hello can anybody suggest a method to make my rotary encoder not be so sensitive?
Also any code creatique would be appresciated
critiques**
terrible typer my appologize
Figured it out just needed to swap the values around when encoder goes above or below the contstrained range. Menu is working perfectly now! Finally I can move on. If anybody could still critique the code it would be appreciated. If this is not the right place any suggestions to somewhere better would also be appreciated.
can i add a new avr MCU in avrdude? for example avrdude does support ATmega32 but now ATmega32A so is there a way i can program that MCU with avrdude?
I would like to use Adafruit UF2 bootloader for both Arduino and CircuitPython applications on a Arudino Nano 33. I have successfully installed the bootloader with SD140 in order to be able to do OTA. Now I am struggling to create a working UF2 firmware. I think the problem is that my application is not compiled to start with the right offset. There was apparently an example on this page https://learn.adafruit.com/adafruit-grand-central/uf2-bootloader-details but it is no longer available. Can anyone give a hint how to properly compile an arduino sketch with the right offset?
@sour tide This is related to the question I asked yesterday in the live chat
How many Tactile buttons can i use as a input with a Arduino pro micro?
Im looking for a arduino that i could use 50 tactile buttons with, maybe with a matrix`?
@humble folio you could use a shift register
Parallel in serial out
Tie the output to the input pin of the microcontroller
@balmy spade the offset is 2k on samd21 and 8k on samd51 iirc
โMake sure that your program was compiled to start at 0x2000 (8k) for M0 boards or 0x4000 (16kB) for M4 boards. The bootloader takes up the first 8kB (M0) or 16kB (M4). CircuitPython's linker script is an example on how to do thatโ
Is what the article says. But when I look at the memory map in https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather/hathach-memory-map I would need to put it right after the softdevice on 0x26000
ah, then I'm wrong ๐
@sour tide I guess the first article does no consider he existence of a soft device. So 0x26000 it shall be. I Need to figure out how to do it with linker ld script.
@balmy spade The Arduino board support package for the Arduino Nano 33 BLE uses mbed as its lower HAL library, and does not use the SoftDevice. So I don't think you will necessarily be able to switch back and forth between Arduino and CircuitPython with that board. The nRF52840 Feather has its own Board Support Package which is quite different from the Nano, even though both use the nRF52840.
If no soft device, the entry point for the bootloader is 0x800 if Im not mistaken
Both the nordic and the DFU bootloaders
Or not DFU sorry, I forget what its called
Fun fact though, the nrf52 actually doesnt have a hard set entry address
You can configure it with your programmer
(But usually the bootloader is used)
Has anyone used the DotStar library with an ATTINY1606 or another x06 MCU?
I get this error when compiling: https://pastebin.com/FD172rC6
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I'm using megaTinyCore and I have had success using the NeoPixel library, but now I'm working with DotStar
And I'm just trying to upload the example strandtest
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
The sketch compiles fine for Uno
@steep robin looks like that library does not have ATTINY support as a whole, its defaulting to using another board
Probably some ATMEGA chip
@steep robin if you wanted to put in the time, the USI peripheral in the ATTINY looks like a good choice to add support
Thank you sir/madam
The APA102 library by Pololu works fine, so there is a solution. Just wondering mainly if anyone had the Adafruit library working. Thanks for the info!
Is there any products on the market which offers intelligent displays (integrated controller) like Nextion or 4D Systems that offer 24bit color range? Looks pretty empty, and those gradients look terrible at 16k colors -.-
@stable forge My naive assumption was that as long as I adjust the linker to use a memory address for the Ardunio payload ( mbedos + compiled sketch) to a memory address after the softdevice this could work. However, I can see the flaws in my thinking. E.g. how will the bootloader know from which address to start the Arduino payload when it probably wants to start the soft device. I guess this would require to alter the bootloader, too. In turn this means that this would require two different bootloaders for arduino and circuitpython. Right?
@vagrant tree Maybe some modules using FTDI's EVE2 controller? The FT812 and FT813 seem to support 24-bit color. https://www.ftdichip.com/EVE.htm
USB RS232 - FTDI designs and supplies USB semiconductor devices with Legacy support including royalty-free drivers. Application areas include USB RS232, (USB Serial), USB Parallel, USB Docking Stations and upgrades of legacy designs to USB.
@cedar mountain Thanks a lot for the hint, will give it a check ๐
It might be possible to load the mbed Arduino program at 0x26000. But it would involve changing the scripts and settings in the Arduino BSP for the nano to set that start address, so that the address computations are correct in the linked binary. And the UF2 bootloader makes an assumption that the softdevice will be in use, and does some setup (interrupt vectors).
Two bootloaders is easier, but then you have to switch back and forth.
This is all a lot of work for a problem that can be solved by just buying another board (Nano or an Adafruit nRF board). It depends on what your time is worth ๐
Ideally I want to have DFU OTA with the nano. I guess I will probably rewrite my project with circuitpython - that should be the best option to achieve what I want. I would go with the adafruit feather sense but I am not sure how it compares power consumption wise to the nano 33 ble+ I would have to change from lsm9ds1 to the sensors used on the adafruit board.
@balmy spade we don't have DFU OTA now with our bootloader, though we are thinking about it. The Feather Sense does not have the power control over the onboard I2C devices that the Nano does. We have started to add this kind of control to newer boards, now that we are thinking and implementing low power (e.g. deep sleep). So it depends on whether you are trying to sleep.
There's no shame in using the Arduino BLE capabilities: if that matches what you need, then go for it.
sorry, I am wrong, we do have the DFU OTA
Ok thanks for the help. Saved my quite some time I guess. I will look into circuitpython. On first sight it might even have more capabilities that are interesting to me such as BLE pairing.
Not sure if this is the place to ask this question, but it's similar to arduino i guess?
So i use a pic18f25k50 with a FOSC of 48MHz (FOSC/4), I use timer1 as a 16-bit timer and i have a prescaler of 1:1. How do i calculate the frequency of my timer?
i was thinking of this:
F = FOSC/ (4 * prescaler * startValue) but im not sure if this is the correct formula
What do you mean by "frequency", I guess?
How often the timer flag triggers i guess
So the idea was to get a frequency of 1 KHz and i wanted to change my startValue accordingly
(Sorry, I was looking at Timer0 rather than Timer1, hang on.)
dw, i apreciate the help!
It looks like the start value will only affect the time until the first rollover, and then after that it'll just count back up to 0xFFFF forever. To get a defined frequency, I think you need to use the Capture Compare module (CCP) in combination with the timer.
i think if i'd add a timer reset to the startValue at my interrupt routine, so after clearing my flag will cause it to be at a certain frequency
something like this
TIMER1
BTG LATB,0
BCF PIR1, TMR1IF
MOVLW "StartValue"
MOVWF TMR1H
return```
That will also work, yep. The start value would need to be calculated as 0xFFFF - offset, since you want to start the timer a little bit below the rollover point.
btw, is there a text channel which i can specifically ask questions about microcontrollers? dont wanna mess up the structure of this server.
#help-with-projects is the usual catch-all channel for technical questions that don't fit into a particular defined topic.
okay, i will continue there if that's okay for you?
My goal is to have microphone amplifier onboard (Neotrellis M4 Express) by connecting STEMMA port because I do not want to use headphone with built-in mic to record. For some reason, it does not success. I attempted to code snippet from Neotrellis M4 Library example. Changed to AudioInputAnalogStereo audioIn(PIN_MIC, A4); It was failed. So my 2nd attempt changed to PIN_WIRE_SDA. still fail. Perhaps microphone amplifier GND VCC OUT is not work connect to GND VCC SDA. What is the correct code to use STEMMA port?
I'm not sure what you are trying to achieve... but... STEMMA ports are the I2C serial bus, and connect to the I2C pins on the processor. The microphone amp is connected to one of the analog input pins on the processor. Were you thinking of using the STEMMA connector as just a way to get access to a different pin on the processor with a connector? This probably won't work: a) It will clash wit any other i2c connected things, 2) those lines are wired with pull-up resistors, 3) I don't even know if the pin it is tied to is capable of analog input.
Or are you trying to connect an i2c based audio preipheral?
hay im new to scripting i have worked with some scripting but im not up to writing a complete script on my own if i can find someone i can get help with scripting?
a clock right?
yeah but not fully im working with buttons to set time because i figured out that i need a way to set the time on the rtc externally from the computer so i have buttons setup on the board
you can set the rtc with buttons, but one thing at a time
to use all these things (expanders, rtcs, etc) libraries are very helpful
Well im not running the clock on a lcd im using leds to display the time so i was thinking having the led flash what is selected to change
a good idea
eventually make it into more of a clock face?
yeah i can connect but scripting is the issue
my advice is to break the problem down into smaller chunks first
so i know i want to do while loop for when the button is =0 state to run the main script
then if the button gets pushed the state goes to a 1 which would be min change again for state 2 for hour change
that's the menu system, one chunk
and if the state is in that it would stop the while loop and run time change script
for something to be responsive you want to check buttons and display time all the time in the main loop
does you have it so it displays time already?
yeah it would be all in one script and yeah its showing the correct time now
but i was thinking if the rtc battery dies and no power rtc will reset time to default so buttons comes in the correct it
rtc batteries are usually good for 5 - 10 years, but having buttons to set the time is nice
so for the button state i was thinking of something like setup = 0
for button count 0 would be clock running state
so one chunk is detecting button presses and keeping a count of them
@obtuse spruce Yes, I was trying to connect an i2c or ADC based audio peripheral. Few hours ago, I discovered that PJRC Synth System Tool uses Microphone Amplifier module and it works on Teensy board. I am assuming that might work with Neotrellis M4 board because that is where I learned from John Edgar Park's tutorial using those kind of tool. I typed AudioInputAnalog A5; (connected Microphone Amplifier module OUT to SDA on STEMMA port)
https://www.pjrc.com/teensy/gui/?info=AudioInputAnalog
No luck. However, I am not giving up ๐
sorry @reef ravine ill dm you later stuff just happend i cant focus and i have to put this on pause for the night
or for right now
ok good luck!
thanks
I wanted to post this here. Someone in this channel helped me with my water sensor (I needed a larger resistor to pull down the digital pin to ground and make the water crossing over the sensor more sensitive). Here is my finished project: https://youtu.be/TYNeofcWZgk
This is a $5 water sensor with push messages to phone. I used the Arduino IDE and a hiletgo from amazon and a few parts from Adafruit.
thanks so much!
(it was a while ago). github code is in video description
Just to clarify. With power control over I2C you mean to switch off sensors when they are not needed?
In comparison to the nano 33 ble the feather sense has the interrupt of the lsm6ds33 connected which is crucial for waking due to movement in my project. Would need a mixture of both boards ideally.
With power control over I2C you mean to switch off sensors when they are not needed?
Yes, on the Nano the sensors are powered from a GPIO pin, which you can turn on and off. This is not true on the Sense.
That's the maximum resistance @wooden wagon
So you may need more voltage to get a reading or what?
Normally you'd have the potentiometer input at a fixed voltage and measure the output voltage to determine the resistance of the pot
So does it really matter if 10k or 100k? I donโt really get that part
Well what are you actually using the pot for? Are you trying to work out its angle, for instance?
Iโm reading the analog signal and use the value for a delay
So the pot is set up as a voltage divider (one end at 0V and one end at your ADC supply voltage)?
Measuring the voltage on the wiper as an analog value?
In that case, the value of the pot doesn't matter much. A higher value pot will draw more power and provide a lower impedance signal to the analog input. The analog input pin is high impedance, so it doesn't need a low impedance signal (but lower impedance can add noise resistance). So a very high value (like 10meg) might give you noise problems, and a very low value (like 100ฮฉ) would waste power and make heat, but in-between, 10k or 100k is fine.
Thanks
hi, im currently trying to make a clock with leds on arduino. I have created the turning motion, however i cannot find how to keep the led turned on after the turning motion is complete
this is what im trying to do
and this is what i have
Can you share the code with us @fierce heron ?
here you go
int del = 150;
int x = 13;
void setup()
{
int inMin = 2;
int inMax = 13;
for(int i=inMin; i<=inMax; i++)
{
pinMode(i, OUTPUT);
}
Serial.begin(9600);
}
void loop()
{
digitalWrite(2, HIGH);
delay(del);
x = 13;
while(x >= 2){
digitalWrite(x, HIGH);
delay (del);
digitalWrite(x, LOW);
Serial.println(x);
x--;
}
}
plz next time put ``` before and after your code so it looks more readable like
this
But anyways you should just be able to add a second counter before or after your while loop to pull the LEDs up
or even better a second while loop
int del = 150;
int x = 13;
int y = 13;
void setup()
{
int inMin = 2;
int inMax = 13;
for(int i=inMin; i<=inMax; i++) {
pinMode(i, OUTPUT);
}
Serial.begin(9600);
}
void loop()
{
digitalWrite(2, HIGH);
delay(del);
x = 13;
y = 13;
while(y >= 2) {
digitalWrite(y, HIGH);
y--;
while(x >= 2) {
digitalWrite(x, HIGH);
delay(del);
digitalWrite(x, LOW);
Serial.println(x);
x--;
}
}
}
@fierce heron
i want to be able to use AT commands with the hc-05 but I cant seem to get it working. there aren't a lot of tutorials out there. any links or suggestions would be really helpful
Hey, in regards to adding ATTINY support to the DotStar library: where did you look to find out that it wasnโt supported? I wouldnโt mind using this as a learning experience and attempting to add the support, so do you have any recommendations on how to get started with that?
Feel free to PM me instead of talking through it all here.
@steep robin so, I just looked at the github repo and here's a starting point: https://github.com/adafruit/Adafruit_DotStar/blob/master/Adafruit_DotStar.cpp#L169
It looks like there's Tiny85 support but not any other Tiny parts.
Now, the Tiny parts all work vaguely alike, so it may be so simple as just adding some other Tiny parts to the list of IFDEFs or it could be more complicated than that.
But I do know that the FastLED library supports a wider set of Tiny parts and their SPI code lives here: https://github.com/FastLED/FastLED/tree/master/src/platforms/avr
GitHub
The FastLED library for colored LED animation on Arduino. Please direct questions/requests for help to the FastLED Reddit community: http://fastled.io/r We'd like to use github "...
I just read your error and its using peripherals for another microcontroller, so the preprocessor definitions are not there for your attiny
Ahhh ok. Iโm starting to see where the platform definitions are. I can see them in the FastLED library too. This might get me started, I can ask more specific questions later when I need more help!
Hey all, I could use some help with my sound sensing arduino code for an LED display I have setup. I am using the FastLED library to use the input from a microphone wired to an analog input which then tells which LEDs to display based on its volume (to the best of my abilities, not very experienced at Arduino coding.) It works as intended, but only for a certain portion. The strange problem I am having is that the the first LED I tell in the code to light based on the sound does as it is intended with LEDs 420 and 422 in this instance, staying a solid color when the sound level is consistent and 422 disappearing when it drops below that volume, but the next LEDs ( 421 & 423) I also define in that if statement start flashing so fast I am having issues counting how many times it flashes in a second, regardless of the sound level. I have tried troubleshooting this many times and can't figure out why this is happening, can anyone be of assistance? (Also if you have any advice on how to condense my code/make it easier to do please say so) ```#include "FastLED.h"
#define DATA_PIN 3
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 882
#define BRIGHTNESS 255
int sensorPin = A1;
int sensorValue = 0;
int thold1=25;
int thold2=50;
CRGB leds[NUM_LEDS];
void setup() {
pinMode(sensorPin, INPUT);
Serial.begin(9600);
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
sensorValue=analogRead(sensorPin);
Serial.println(sensorValue);
if (sensorValue>thold1)
leds[420]=CRGB::White;
leds[421]=CRGB::White;
FastLED.show();
if (sensorValue<thold1)
leds[420]=CRGB::Black;
leds[421]=CRGB::Black;
FastLED.show();
if (sensorValue>thold2)
leds[422]=CRGB::White;
leds[423]=CRGB::White;
FastLED.show();
if(sensorValue<thold2)
leds[422]=CRGB::Black;
leds[423]=CRGB::Black;
FastLED.show();
}```
Here is a video of it happening. Bottom is LED#420, and increasing in number going up the strip
What do you intend to happen when the value is equal to the threshold?
LED displays the color and stays on until the the value dips below the threshold
So greater than is white, equal is color, less than is black?
Er sorry, Greater or equal to is white, less than is black
There are a lot of ways to condense the code, but my first pass would look something like this:
leds[420] = leds[421] = (sensorValue < thold1) ? CRGB::Black : CRGB::White;
leds[422] = leds[423] = (sensorValue < thold2) ? CRGB::Black : CRGB::White;
FastLED.show();
Arduino: 1.8.13 (Linux), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
In file included from /home/pi/Arduino/Microphone_input/Microphone_input.ino:1:0:
/home/pi/Arduino/libraries/FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.003
pragma message "FastLED version 3.003.003"
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pi/Arduino/Microphone_input/Microphone_input.ino: In function 'void loop()':
Microphone_input:24:54: error: expected primary-expression before ':' token
leds[420] = leds[421] = (sensorValue < thold1) ? CRGB:Black; : CRGB:White;
^
Microphone_input:24:55: error: 'Black' was not declared in this scope
leds[420] = leds[421] = (sensorValue < thold1) ? CRGB:Black; : CRGB:White;
^~~~~
Microphone_input:24:62: error: expected primary-expression before ':' token
leds[420] = leds[421] = (sensorValue < thold1) ? CRGB:Black; : CRGB:White;
^
Microphone_input:25:54: error: expected primary-expression before ':' token
leds[422] = leds[423] = (sensorValue < thold2) ? CRGB:Black; : CRGB:White;
^
Microphone_input:25:62: error: expected primary-expression before ':' token
leds[422] = leds[423] = (sensorValue < thold2) ? CRGB:Black; : CRGB:White;
^
exit status 1
expected primary-expression before ':' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I get the above error when I paste that into the code unfortunately
There's an extra semicolon after CRGB:Black
i have 8 strips connected to an ESP32 and 1 PSU source now about the 1000 ยตF, 6.3V capacitor i only add 1 right or 1 for each strip?
Depends somewhat on the length of the strips. But more capacitance is rarely bad.
i ordered 100 1000 ยตF, 6.3V capacitor so why not add 1 on each strip xD
even tho they are not THAT long
I'm sorry, I have ```#include "FastLED.h"
#define DATA_PIN 3
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 882
#define BRIGHTNESS 255
int sensorPin = A1;
int sensorValue = 0;
int thold1=25;
int thold2=50;
CRGB leds[NUM_LEDS];
void setup() {
pinMode(sensorPin, INPUT);
Serial.begin(9600);
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); // initializes LED strip
FastLED.setBrightness(BRIGHTNESS);// global brightness
}
void loop() {
sensorValue=analogRead(sensorPin);
Serial.println(sensorValue);
//if (sensorValue>=thold1)
// leds[420]=CRGB::White;
// leds[421]=CRGB::White;
// FastLED.show();
//if (sensorValue<thold1)
// leds[420]=CRGB::Black;
// leds[421]=CRGB::Black;
// FastLED.show();
//if (sensorValue>=thold2)
// leds[422]=CRGB::White;
// leds[423]=CRGB::White;
// FastLED.show();
//if(sensorValue<thold2)
// leds[422]=CRGB::Black;
// leds[423]=CRGB::Black;
// FastLED.show();
leds[420] = leds[421] = (sensorValue < thold1) ? CRGB:Black : CRGB:White;
leds[422] = leds[423] = (sensorValue < thold2) ? CRGB:Black : CRGB:White;
FastLED.show();
}``` I don't have an extra semicolon after CRGB::Black, Not sure why the console says there is
Arduino: 1.8.13 (Linux), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
In file included from /home/pi/Arduino/Microphone_input/Microphone_input.ino:1:0:
/home/pi/Arduino/libraries/FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.003
# pragma message "FastLED version 3.003.003"
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pi/Arduino/Microphone_input/Microphone_input.ino: In function 'void loop()':
Microphone_input:42:54: error: expected primary-expression before ':' token
leds[420] = leds[421] = (sensorValue < thold1) ? CRGB:Black : CRGB:White;
^
Microphone_input:42:61: error: found ':' in nested-name-specifier, expected '::'
leds[420] = leds[421] = (sensorValue < thold1) ? CRGB:Black : CRGB:White;
^
Microphone_input:42:55: error: 'Black' has not been declared
leds[420] = leds[421] = (sensorValue < thold1) ? CRGB:Black : CRGB:White;
^~~~~
Microphone_input:43:54: error: expected primary-expression before ':' token
leds[422] = leds[423] = (sensorValue < thold2) ? CRGB:Black : CRGB:White;
^
Microphone_input:43:61: error: found ':' in nested-name-specifier, expected '::'
leds[422] = leds[423] = (sensorValue < thold2) ? CRGB:Black : CRGB:White;
^
Microphone_input:43:55: error: 'Black' has not been declared
leds[422] = leds[423] = (sensorValue < thold2) ? CRGB:Black : CRGB:White;
^~~~~
exit status 1
expected primary-expression before ':' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.```
This is still the error.
Oh, I goofed, the colons should be double colons
so i have this buttonState = digitalRead(mcp6.pinMode(0, INPUT)); under void loop but i get invalid use of void expression?
You arent passing the pin name, but a function that sets it as input
sorry should posted more of the script
int buttonState = 0;
top of the script not in a void
mcp6.begin(B101);
mcp6.pinMode(0, INPUT);//Setup
mcp6.pinMode(1, INPUT);//Up
mcp6.pinMode(2, INPUT);//Dow
and i want the atmega to read the mcp input to the pin
because i want to have a button to change the buttonState 1-5 because each state of the number has a pacific script to run
#include <Wire.h>
#include "RTClib.h"
#include <Adafruit_MCP23017.h>
#define NUM_ONES_LEDS 4
#include <SevSeg.h>
RTC_DS3231 rtc;
Adafruit_MCP23017 mcp1;
Adafruit_MCP23017 mcp2;
Adafruit_MCP23017 mcp3;
Adafruit_MCP23017 mcp4;
Adafruit_MCP23017 mcp5;
Adafruit_MCP23017 mcp6;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int sel = 0;
int buttonState = 0;
void setup () {
mcp6.begin(B101);
mcp6.pinMode(0, INPUT);//Setup
mcp6.pinMode(1, INPUT);//Up
mcp6.pinMode(2, INPUT);//Down
void loop () {
buttonState = digitalRead(mcp6.pinMode(0, INPUT));
if (buttonState == HIGH){
sel++;
if (sel >=5){
sel = 0;
}
}
of all the libraries for rotary encoders do you guys know one that does not use external interrupts and support button click
@twin ginkgo use ```
buttonState = mcp. digitalRead(0);
in the void loop?
yeah
ok thanks
does anyone know how to script an RTC?
You can basically do three things with an RTC: set it, read the current time, and get an alarm
i just woundering how to do the set time
if you're using the standard arduino RTC library:
https://www.arduino.cc/en/Reference/RTCsetTime
this is from the PCF8523 guide:
https://learn.adafruit.com/adafruit-pcf8523-real-time-clock/rtc-with-arduino#setting-the-time-2933471-15
Sorry for the delay, was busy with a few things. So I have the LEDs setup to display according to a threshold set by an analog microphone input, but I have the issue where they are flashing uncontrollably instead of staying lit when the threshold is met or exceeded and then turning off when it dips below like intended. This is the code I have: ```#include "FastLED.h"
#define DATA_PIN 3
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 882
#define BRIGHTNESS 255
int sensorPin = A1;
int sensorValue = 0;
int thold1=15;
int thold2=25;
int thold3=35;
int thold4=45;
CRGB leds[NUM_LEDS];
void setup() {
pinMode(sensorPin, INPUT);
Serial.begin(9600);
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); // initializes LED strip
FastLED.setBrightness(BRIGHTNESS);// global brightness
}
void loop() {
sensorValue=analogRead(sensorPin);
Serial.println(sensorValue);
leds[420] = leds[421] = (sensorValue < thold1) ? CRGB::Black : CRGB::White;
leds[422] = leds[423] = (sensorValue < thold2) ? CRGB::Black : CRGB::White;
leds[424] = leds[425] = (sensorValue < thold3) ? CRGB::Black : CRGB::White;
leds[426] = leds[427] = (sensorValue < thold4) ? CRGB::Black : CRGB::White;
FastLED.show();
}```
Here is a video example. My TV in the background is breaking up for some reason. unrelated to the display flashing
Leds # 424, 425, 426, and 427 are the ones flashing, specifically.
Why would they hold? Your code is working based on the instantaneous value of the analogRead().
At 9600, the Serial.println() will, eventually, slow the effective reading rate down to a few hundred hertz
(once the serial transmit buffer gets full)
๐ฆ my ESP32 is stuck on [WIFI][INFO][STATUS] : Connecting to WiFi.. so i take it the WIFI does not work as if i remove the WiFi code part and rerun it, it can control the LED :/
Have you tried checking your wifi credentials?
hello! I have a question. Can i re-flash an arduino like a blank atmega chip, without extra steps, or do i need to reset the atmega chip or something like that?
@everyone ?
there are 26 000 people in this discord. Do you really want to ping all of them?
Fortunately that tag is disabled but it is still extremely rude to use it.
hey i need some help for a project...
is it possible to use an (full)arduino to only get data from other sensors then send it to an OTHER arduino that will only be used as a wifi connection ? gonna use normal digital ports to transfer data between them
ive got an arduino uno and a arduino Wemos D1
but the probleme is that the weemos only has 1 analog port and i need mutiple... also it has wifi and arduino uno dosen't (+ i don't have wifi shield, might get it later, but trying to do witout it atm)
sending data over serial/uart is relatively easy. another option is to use an outboard ADC module on the Weemos, probably I2C
@slow nebula you can indeed use serial (aka UART) to send data between two boards
Or you can just get another board that has it all - wifi and multiple analog ports, such as arduino nano 33 iot. It will cost you $19, but will make your life much easier
wow didn't know that arduino existed.. very usefull thanks !
might get a few of them ^^
the only prob is that i hate soldering (never did in my life.. gonna have to get the habit x) )
soldering is easy - but if you really hate it, you can get one with already soldered headers:
https://store.arduino.cc/usa/nano-33-iot-with-headers
Not only you get analog and digital ports and WiFi, but it also contains IMU (accelerometer/gyro) - which can also be quite handy
One place where you have to be careful: note that nano 33 (like Wemos D1) uses 3.3v signals, and Uno uses 5v. So if you are measuring analog voltage higher than 3.3v, you need to use voltage dividers
**HO YOU SAVED ME **
totally forgot it was 3.3, welp my board is saved 
wil put a small voltage divider to lower to 3.3 ^^
need some help thinking through something.... Im trying to power 8 LEDs where each one has a 5v out and then ground so 16 pins total. i also have a potentiometer which needs analog in, power, and ground
can i fit all that on this board?
Are you constrained to just the board?
yea, it needs to be tiny. also its the only one i have right now
hmmm without getting into too much detail, thats not an option for this setup
each one needs its own 2 pins for in/out
hm
well there are 18 that can be used as digital io pins
and if your pot can be powered by the VCC pin then you only need 1 analog pin to read it
so 17 total with your LEDs, should be doable I would think
from the sparkfun page
hm one sec
You might have trouble doing serial coms over usb that way
You really can't use a shift register or gpio expander?
yes
that's quite a constraint, best of luck!
im making effectively 8p display so really its more than 8 LED its 8 rows of 8 LED, so its important to be able to power only one row and ground one column at once
i guess thats kind of a shift register right?
I think if you code it like one it is
im having trouble flashing my code to this board
i dont see a "pro micro" in this board menu
check out https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/installing-windows for help I think
@lethal wigeon I don't suppose you could help me with a nRF52840 systemOff issue, could you?
Trying to use CLUE in Arduino ide as ble controller; guide examples show his to send char buffers for uart mode but I have not found format for standard packets such as buttonpacket. How do I construct a button packet??
@lavish jacinth you can follow either the play station, or xbox specifications for bluetooth controllers from what I understand, they both implement their own HID layers atop L2CAP
According to stargirl, the PS5 implementation is better but looking at the conversation they could have been talking about something USB specific
(sorry for the ping stargirl)
(point.stop - 0) * (255 - 0)/(1-0) + 0
produces a float value 0.0 how to round it out to an int?
got it working! question, can fastLED Palette take a float as position or does it only allow int?
hey people, i've got an issue with a Arduino Christmas tree project, I dont have an arduino but i bought the product becasue it said that i can power it with 5/9 volts
Hi Iโm working on making a DIY led screen (8x8). The LED are wired in a matrix, where I call each row/column pair one at a time. To light up the whole display I would call every row/column pair in succession, where each LED only stays on for a brief period of time, then persistence of vision makes it feel like a solid image
On smaller scales like 2x2 or 4x4 the lights appear solid, but at 8x8 the flicking is quite obvious
Why is this? Am I reaching the limits of the clock speed of the chip? Arduino MEGA2560
yes and no. Assuming you have pins for each row/column, the trick is to switch a whole row at once instead of each LED individually. In this way you can set a certain pattern for each LED in a given row, and pulse the pin corresponding to the whole row. To further speed things up, it can be an advantage to connect the row pins to pins on the controller corresponding to a full port register, and directly write a byte to the register to switch everything at once. I did something similar recently on a nano: https://streamable.com/66sj5c
Some info on port manipulation here: https://www.arduino.cc/en/Reference/PortManipulation
Open-source electronic prototyping platform enabling users to create interactive electronic objects.
@fierce plank so if I want the first two LED lit in row 1 I should light them both up at the same time instead of one after the next?
@verbal cloak The CD4017 will run on a range of voltages, but I can't read the other chip's part number
I think it's a 555
A 555 will also run on a range of voltages
yep, if they are wired up to a port, you can do something like PORTB = 0b11000000 to set the first two pins instead of digitalwrite.
What is a port in this sense?
Right now I just have it like pins
In and out pins for each row/col
The pins on the controller are grouped into ports. You can find out how they are grouped in a datasheet or online. For example PB6 on this image refers to bit 6 of port B. Internally the state of each port is represented by a byte.
Thanks, but i Worked out the problem
So i realised a little too late i used a 100 ohm resistor instead of a 1K Ohm resistor and i blew the 555 timer
That's a shame.
I would like to transmit from a mobile app to a Clue a variable number of "Locations" which consist of an index (uint8_t), name (char[16]), longitude (double), latitude (double), message (char[128-ish]) over the BLE, what's the best way to do that?
There are a few possibilities. You could use an existing protocol (like Firmata) to handle the data transfer, you could serialize and unserialize it with an existing structure (like XDR or JSON) or roll your own, or you could send the locations one at a time using fixed-sized blocks. Which approach is "best" depends on your use case, system resources, and personal preference.
It might also be useful to know that this data will live in JSON form on the 2MB flash
So just transmit JSON probably
Actually, I think JSON will work fine, I think I can essentially stream it to and from the flash using relatively little RAM
That would probably mean building my own little protocol on top of the BLE UART (which as I understand it, is proprietary to Nordic for the nRF52 stack)?
I assume I can look at Adafruit's Connect app to see how to do the UART from the Android side, yeah?
The last time I looked at BLE and Nordic chips, I got pretty frustrated and didn't make much progress, so I don't have much useful information to offer on that end of things.
So would you say that the Nordic chips have been, at least for you, nRFed?
hey there! Anyone with a few free minutes willing to help me figure out what i'm doing wrong
https://github.com/StegoPhone/StegoPhone-Artemis-Nano/pull/1/files
rn52.cpp:6:9: error: no declaration matches 'StegoPhone::RN52* StegoPhone::RN52::getInstance()'
RN52 *RN52::getInstance() {
^~~~
sketch\rn52.cpp:6:9: note: no functions named 'StegoPhone::RN52* StegoPhone::RN52::getInstance()'
In file included from sketch\stegophone.h:19,
from sketch\rn52.cpp:1:
sketch\rn52.h:15:9: note: 'class StegoPhone::RN52' defined here
class RN52
^~~~
sketch\stegophone.cpp: In member function 'void StegoPhone::StegoPhone::init()':
stegophone.cpp:42:24: error: 'getInstance' is not a member of 'StegoPhone::RN52'
RN52 *rn52 = RN52::getInstance();
^~~~~~~~~~~
sketch\stegophone.cpp: In member function 'void StegoPhone::StegoPhone::loop()':
stegophone.cpp:109:15: error: 'getInstance' is not a member of 'StegoPhone::RN52'
RN52::getInstance()->rn52Status();
^~~~~~~~~~~
exit status 1
no declaration matches 'StegoPhone::RN52* StegoPhone::RN52::getInstance()'
Looks like the header declares RN52 *RN52::_getInstance() while the cpp file is trying to define RN52 *RN52::getInstance()
@pine bramble I would remove the underscore from the declaration since it's public
oh that's a typo
haha ๐
excellent catch!
This is why I miss pair programming
I hear ya!
If that's all it is.... *grumble
wow
i was that close. dang. the circles i went through
๐คทโโ๏ธ
Story of my life ๐คฃ
what's your github user, i want to give you credit!
Aw thanks, I'm @dense flumepeden ๐
pushed ๐
thank you!
now to see if this crazy thing still works.
OMG it works so good
oh baby now i can get moving data!
get on up its crypto time
Nice!
Ok, I'm going to get back it my real job too.
Thanks again!
be my wingman anytime.
Hello awesome people. Wonder if someone can help me with a little code modification using the adafruit_neopixel lib.
The code has the lines
#define STRIP_LENGTH 200
and
Adafruit_NeoPixel strip = Adafruit_NeoPixel(STRIP_LENGTH, NPPin, NEO_GRB + NEO_KHZ800);
I would like to change the code to allow two different lengths(number of) pixels, use an input pulled high or low to set the strip length. I get the idea of setting a pin input and setting a varible like if high 200 else 144 but to do that I would be doing in the void set up and this would be after the line above, my brain has totaly melted. Anyone point me in the right direction.. Thank you ๐
triple back ticks `
or single for single lines, triple lets you do multiple lines
you can do:
```cpp
yourcodehere
```
to have it format it like cpp code
or use "arduino" now that I think about it
@grand knot check this example:
Thank you @vivid rock That makes sense, lets see if I can get all my ==,, in the right places. Cheers for the pointer
so you could have something like this
#define NEOPIXEL_PIN 6 //NP pin
#define INPUT_PIN 1 // digital input pin
Adafruit_NeoPixel *pixels;
int numPins;
void setup(){
pinMode(INPUT_PIN, INPUT_PULLUP);
if (digitalRead(INPUT_PIN)){
numPins=200;
} else {
numPins=144;
}
pixels = new Adafruit_NeoPixel(numPins, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);
}
You sir are a star!
you are welcome ๐
hey, i have an adafruit airlift featherwing that was working fine with circuitpython. now in arduino, when i run ScanNetworks sketch, all it says is Communication with WiFi module failed! in the serial console. i know i'm using the adafruit version because there are references to ADAFRUIT_FEATHER_M4_EXPRESS and stuff like that everywhere.
any advice? (please ping if you answer, thanks in advance ๐ )
The Clue doesn't have a charging circuit?
what is RAW and VCC?
RAW is an input to an onboard voltage regulator. you feed a voltage in and it gets regulated to Vcc. Vcc is the supply for your circuit, it might e 3.3v, 5v, (or other). how high a voltage RAW accepts is board dependent
so VCC is like a 5v out?
i started using a mega 2560 but i move to pro micro, wondering how to get "5v" pin
Vcc is used as a generic term for "supply voltage" On a ProMicro Vcc is a 5v output
it comes from the USB's 5v
wondering if anyone could help me out, looking for a wireless way to transfer small amounts of data between Arduinos, it need to be really low power bc one side will be running of battery though i can go into deep sleep in between data sending. any suggestions?
ping me with any ideas plz
@unborn frost is IR a possibility? Else the nRF24 might be an RF solution.
@unborn frost Bluetooth Low Energy?
Or nrf52 for BLE, or any 802.4.15 based standard such as thread, zigbee, etc. The radio can use a bunch of popular protocols so can try and see what works best
Does anyone have experience with nRF52840 low power modes? The systemOff function in the nRF52 BSP doesn't work for me.
How soon will the MagTag be back in stock? I saw you were making some on last week's made in NYC and I missed them the first time.
Are you using a soft device?
Not sure, I'm using the default setup for the Clue in PlatformIO
Is there any point in doing a free() on malloc()'d objects during a destructor that would never happen since the main object will never destruct unless the thing reboots?
i feel like not putting in the ~destructor with the free() is heretical...
but i don't really see the point in putting in codespace that won't happen?
@pine bramble I usually don't worry about it lol
that was kind of the conclusion i came to... and then we wonder why there's all these missing frees when old embedded devs get their hands on a big 'puter.
๐คฃ
You know, this is totally off the wall, I was going to ask your twitter handle so i could follow you since you're fun and helpful, but i hit the 5k limt and can't follow anyone else until i gain 2k more.. oi first world problems.
Are there any resources or existing programs out there that tells an Arduino Nano or Mega read AC frequency (preferable around 20Hz to 250Hz)? If so... Could I know what it is? XD I can't find much on my end...
You're not missing much, I don't post on twitter much anymore ๐
quick question for debugging something, how do i set a pin so it is constantly low?