#help-with-arduino

1 messages ยท Page 85 of 1

obtuse spruce
#

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.

dreamy minnow
#

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?

obtuse spruce
#

no.. just helping folks here! i should start a coding dojo!

dreamy minnow
#

i mean, you would make a great professor!

obtuse spruce
#

thank you!

dreamy minnow
#

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?

obtuse spruce
#
  • The void in void loop() means "this function doesn't return anything"... so we refer to that function as loop()
  • if (x) is exactly the same as if ((x) == true) There is never a reason to explicitly check for equality to true: Something is equal (==) to true if and only if it is equivalent to true. if doesn't need a test operator (like == or <) -- it just needs something that is true or false (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."

dreamy minnow
#

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?

obtuse spruce
#

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.

dreamy minnow
#

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".

obtuse spruce
#

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

dreamy minnow
#

and only then it will be completed

obtuse spruce
#

Actually - the clearInputs() call in the if is optional!! It depends on if you want to consider "reflashing"... or if all must "flash again"

dreamy minnow
#

this is so much fun

obtuse spruce
#

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?

dreamy minnow
#

and won't a weird input, say, for some reason a light flashes two times, fill the onTime arrary?

obtuse spruce
#

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!

dreamy minnow
#

also yes, great point

obtuse spruce
#

So much of programming isn't really about getting your code right ... it is about really understanding the problem you are trying compute.

dreamy minnow
#

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

obtuse spruce
#

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.....)

dreamy minnow
#

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!

fallen dome
#

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

cedar mountain
#

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.

stuck coral
#

ESP32 but its very poor quality

paper mist
#

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

obtuse spruce
#

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.

paper mist
#

ah nice

#

but is there a list of keycodes i can use in either library?

obtuse spruce
#

P. 58 has what you are looking for

paper mist
#

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

obtuse spruce
#

Those aren't keycodes. Those are characters.

paper mist
#

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?

obtuse spruce
#

What library call are you using? Again those aren't scancodes

paper mist
#

i know they aren't scancodes, i don't know what else to call them lel

#

i believe this is the adafruit_keypad library

obtuse spruce
#

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.

paper mist
#

ahah, i see it now scrolling through the rest of the code

#

makes much more sense now, thank you

obtuse spruce
#

But.. just use any spare characters you want.

paper mist
#

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

pine bramble
#

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?

obtuse spruce
#

Sanity check: do you periodically see the output on the Serial lines?

pine bramble
#

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}]}
obtuse spruce
#

okay - good...

pine bramble
#

c should be 1 for any change caused pulse.. and the corresponding v= should b 1 and t > 0

obtuse spruce
#

an aside - your volatile annotations aren't needed here --- you aren't trying to keep the compiler from reordering things.

pine bramble
#

I had them since they could be changed inside an isr

#

so the compiler wouldnt optimize out.

obtuse spruce
#

c will always be 0 --- you set sendData = false two lines above.

pine bramble
#

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 ๐Ÿ™‚

obtuse spruce
#

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.

pine bramble
#

excellent. I figured I was playing it safe there.

#

Its been a few years since i have done microcontroller code on the daily.

obtuse spruce
#

Okay - SO - if "c"=0 all the time, then we know that isrDigitalPinChange is never getting called.

pine bramble
#

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

obtuse spruce
#

which board is this?

pine bramble
#

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 ๐Ÿ™‚

obtuse spruce
#

From what I can tell, only pins 0, 1, 2, 3, & 7 can interrupt

pine bramble
#

oh!

#

7 was one that worked..

#

sigh. where did you catch that in the docs?

obtuse spruce
#

Arudino's own docs always seem incomplete to me.

pine bramble
#

im not sure I can use 0 since it's tx?

#

1 for rx...

obtuse spruce
#

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

pine bramble
#

or is 0 = a0 on the right side?

#

im going to go back to the diagram... sorry. ๐Ÿ™‚

obtuse spruce
#

no - 0 (digital) is RX on the upper left

pine bramble
#

ok. thought so.

obtuse spruce
#

(Arduino pin numbering.... is a special snowflake!)

pine bramble
#

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

obtuse spruce
#

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.

pine bramble
#

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.

#

?

obtuse spruce
#

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?

pine bramble
#

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!

obtuse spruce
#

It won't

#

people leave their sketches with non-stop loop() running for DAYS

pine bramble
#

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

obtuse spruce
#

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!

pine bramble
#

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 ๐Ÿ˜›

obtuse spruce
#

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....

pine bramble
#

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.

obtuse spruce
#

...had to canabalize another project to have a board to work with in time.

pine bramble
#

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

pale shell
#

Am I clear to ask my question or are you guys still talking?

pine bramble
#

always free!

#

sorry for giving the impression of usurpation. I'm good ๐Ÿ™‚

pale shell
#
#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)

pine bramble
#

Thanks for your help earlier, I have a solution almost working! ๐Ÿ™‚

#

ducking out!

kindred canyon
obtuse spruce
#

@pale shell what are you expecting the pins to do while the state is 'r'?

pale shell
#

Set the motor controller to drive the motor backwards

obtuse spruce
#

It just looks like loop will write the same values again and again

pale shell
#

The values it writes between R and F are different

#

If that's what you meant

obtuse spruce
#

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.

pale shell
#

oh

#

Would putting the logic into my on receive for the i2c work?

obtuse spruce
#

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?

pale shell
#

10, 9, 8, 7

obtuse spruce
#

that's to inputs 1, 2, 3, 4.

pale shell
#

Yes

obtuse spruce
#

what is connected to ENA and ENB?

pale shell
#

Nothing, I have the jumpers attached

obtuse spruce
#

so the motors are just going to run full speed... all the time ... that is your intention, right?

pale shell
#

Yes

obtuse spruce
#

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()

pale shell
#

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?

obtuse spruce
#

dunno - about the nano....

#

Welllll... do you have a spare LED and resistor? You can use that to debug!!

pale shell
#

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.)

obtuse spruce
#

that's good, too! So - you are certain that your commands are causing the proper state value to be seen in loop

pale shell
#

yup

obtuse spruce
#

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

pale shell
#

Lemme grab my multimeter quickly

#

It seems I've lost my multimeter

#

I'll grab an led then

obtuse spruce
#

and a resistor!

pale shell
#

Yup I know, trying now

#

...and now it's working?

obtuse spruce
#

test the other pins....

pale shell
#

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

obtuse spruce
#

that makes little sense --- since sending the same command twice in a row shouldn't change the state of the output pins at all

pale shell
#

That'ss why I'm confused

obtuse spruce
#

(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.....

pale shell
#

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

obtuse spruce
#

er... never mind... I'm not sure

#

did you connect ground?

pale shell
#

Yup

#

The pi and arduino share a common ground

obtuse spruce
#

gooooood

#

okay - power!

pale shell
#

I guess that the raspberry pi's 5v output isn't stable enough

obtuse spruce
#

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

pale shell
#

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

paper mist
#

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)

pale shell
#

oops sorry just saw your message. Based on what I've seen you access analog pins through names like "A0" or "A1"

obtuse spruce
#

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.

pale shell
unborn pumice
obtuse spruce
#

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. ...

unborn pumice
#

how do i access the value of like 100 in first one

#

like colourValues[0][0] does nothing

obtuse spruce
#

That unit says 2.4A... but who knows if it will for a Pi!

pale shell
#

Hmm I'll have to look into that

paper mist
#

@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?

obtuse spruce
#

@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]));

paper mist
#

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);```

unborn pumice
#

also my serial.print only prints two letters from

#

Serial.print("test"); prints out te

pale shell
#

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

unborn pumice
#

when called from interupt

paper mist
#

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"

obtuse spruce
#

@unborn pumice - don't call Serial.print inside an interrupt!

paper mist
pale shell
#

Just curious, what happens if you call Serial.print in an interrupt?

obtuse spruce
#

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!

pale shell
#

Ah

obtuse spruce
#

(note - some board core libraries could have protection for some Serial devices... but I don't know of any.)

pale shell
#

It seems that the raspberry pi is working successfully when powered off my laptop usb ports so that may be promising

unborn pumice
#

this literally makes no sense

#

supposed to make the rgb light go red

#

but it goes yellow from a 255,0,0 write

obtuse spruce
#

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?

pine bramble
#

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?

obtuse spruce
#

Also, you can cut-n-paste your code nicely by putting the whole thing between triple-back-ticks like this:
```C++
int colourSelect = 0;
```

unborn pumice
#

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

obtuse spruce
#

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.

unborn pumice
#

i just set as INPUT

#

does it need to be INPUT_PULLUP

obtuse spruce
#

well - do you have an external pull-up or pull-down resistor?

unborn pumice
#

nah

obtuse spruce
#

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)

unborn pumice
#

its literally just connected to a digital pin then grounded

obtuse spruce
#

so the other end is GND - fine - then you need a INPUT_PULLUP

unborn pumice
#

yeah i changed now

obtuse spruce
#

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.

dreamy rover
#

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.

dreamy rover
#

welp... disregard. Looks like I have a bad board.

#

somehow there's a short in the board.

twin ginkgo
#

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

crisp crag
#

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?

crisp crag
woven mica
crisp crag
woven mica
crisp crag
woven mica
#

yes

crisp crag
#

im having issues with it but ill have to attempt this again as the port busy errors D:

broken gulch
#

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?

obtuse spruce
#

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.

broken gulch
#

Thanks Iโ€™ll try those recommendations

formal onyx
#

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.

north stream
#

Hmm, is it a 3.3V Nano or a 5V one?

formal onyx
#

Im not sure. Digital pins output 5v, if that tells you

north stream
#

Ah, okay. That is weird.

#

I wonder if an isolation diode has failed.

formal onyx
#

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.

north stream
#

Agreed.

formal onyx
#

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.

#

Yep. Working fine with A0 and A1.

strange torrent
#

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)

vivid rock
#

OLED display uses the same i2c bus as used for communication between M4 and nano?

strange torrent
#

Yes

vivid rock
#

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)

strange torrent
#

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

cedar mountain
#

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.

elder hare
#

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!

strange torrent
cedar mountain
#

You're still seeing the crash?

strange torrent
#

yes

cedar mountain
#

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.

strange torrent
#

okay, thanks for your help. I will look into those

shrewd wyvern
#

hey quick question the DC barrel on Arduino Uno the inner part is the +5V right?

stuck coral
#

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

shrewd wyvern
#

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

stuck coral
#

It can

#

Usually it can go up to 9v

#

Sometimes 12v, but always check

shrewd wyvern
#

yep I'll let it run for some time to see if I have heat problems

stuck coral
#

You will if you are drawing a fair amount of current, its a linear regulator, so extra energy is just wasted as heat

shrewd wyvern
#

yep I don't think I am drawing that much.. I usually use the 1 night running test :p

neon flicker
#

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

obtuse spruce
#

? 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.

opaque laurel
#

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.

ionic wagon
#

Hello, how do you turn off a led strip. Knowing that this led strip uses adfruit libraries

#

Or to refresh the led strip

odd fjord
#

Is it a neopixel strip or just LEDs

ionic wagon
#

Yes is a neopixel strip

odd fjord
#

write strip.fill(0) to turn them off

#

or whatever you used for strip

ionic wagon
#

OK thank you

odd fjord
#

sorry -- this is arduino...

#

I was thinking Circuitpython

ionic wagon
#

Yes is arduino

odd fjord
#

my mistake - forgot which channel I was in.

ionic wagon
#

OK

odd fjord
#

you should be able to do strip.fill(0); strip.show();

ionic wagon
#

I'm going to try

odd fjord
#

or strip.clear()

ionic wagon
#

His function

sage osprey
woven mica
sage osprey
#

Thank you!

pine bramble
#

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.

pine bramble
#

does Adafruit do same day delivery?

wraith current
#

they ship from NY so probably not.

#

but amazon might have some of their products

pine bramble
#

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

remote viper
#

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!

wraith current
#

@remote viper AdurinoJson is a library for parsing json. But it can be a bit heavy on the memory too.

remote viper
#

@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.

stuck coral
#

"bit"

#

Just a little ๐Ÿ˜‰

remote viper
#

... If I can recall my C from ~30 years ago ๐Ÿ™‚

shrewd wyvern
#

The JSON library is indeed a memory hog

stuck coral
shrewd wyvern
#

go go protobuf and gRPC

#

at them moment JSON is more something that makes your system easy to integrate

stuck coral
#

In the scope of a single endpoint sure

shrewd wyvern
#

what do you mean?

stuck coral
# shrewd wyvern 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

shrewd wyvern
#

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

stuck coral
#

Yep

#

Its cool you can read it as a human ig

#

Not sure how often that happens though

shrewd wyvern
#

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

stuck coral
#

Also, if you handle say 1 million requests, the amount of overhead is pretty large

shrewd wyvern
#

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

stuck coral
#

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

shrewd wyvern
#

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

stuck coral
#

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

shrewd wyvern
#

I've heard about, also have been working with golang..

stuck coral
#

Golang is awesome too, love em both

#

But I dont like a garbage collector in my kernel ๐Ÿ˜œ

#

Idk about you

shrewd wyvern
#

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

stuck coral
#

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

shrewd wyvern
#

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

stuck coral
#

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

remote viper
#

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");
stuck coral
#

Talk about business point of view productive

stuck coral
#

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

remote viper
#

oh, got ya. okay. thanks!

stuck coral
#

You could also shorten this with sprintf

remote viper
#

I miss Python already, lol.

stuck coral
#

ew

#

I had to use python today....

#

I used to like it

remote viper
#

Well, i'm honestly not a fan either. I most "code" in PowerShell. But, well... I'm working on embedded stuff ๐Ÿ™‚

pulsar junco
#

Hey let's just be glad we're not using VBA

stuck coral
remote viper
stuck coral
#

Right, so you want all strcat my bad

#

Or strncat if you dont like living in the danger zone

shrewd wyvern
#

ahah

#

and try to make sure you have enough space for that string

stuck coral
#

Hence the danger zone part XD

remote viper
#

I'm sure there is a 10k word thesis on the difference between the two, of course.

shrewd wyvern
#

nah not really

#

just a man page :p

stuck coral
#

Strncat also takes a size variable, if you feel like having code look like its not from the 80s

remote viper
#

Yeah, I see the difference now. Makes sense

stuck coral
#

There are in fact thesis on that

#

And many more, more mundane things.

shrewd wyvern
#

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.
remote viper
#

Ah, buffer overruns, fun... Yes. Right. I'm dealing with low level languages now ๐Ÿ™‚

stuck coral
#

So I always put the size variable as sizeof(buffer)-1

pulsar junco
#

I got a stern look from a prof for calling C low level once. But he taught assembly

stuck coral
#

Can also do some fancy preprocessing if you dont wanna do the math every time

stuck coral
shrewd wyvern
#

ahah

pulsar junco
#

IIRC punchcards are where "patch" comes from. At least that's the trivia I have decided to go with

stuck coral
#

Huh

pulsar junco
#

like you'd "patch" over punch(es) to make changes to the program

remote viper
#

Paper tape, actually (re:patch)

#

but close enough.

shrewd wyvern
#

Just one thing you said you were using ArduinoC but Arduino is C++ so you actually have a library to handle strings

remote viper
#

I learned FORTRAN on a PDP-11 teletype (I was auditing a college class with my dad - i'm not quite that old)

shrewd wyvern
#

If you are coming from Python I think you will have easier time :p

remote viper
#

I've got about 20k lines of PowerShell in the repository at work but... well, that's no better than Python, really ๐Ÿ™‚

stuck coral
remote viper
#

I mean orange, I suppose

stuck coral
#

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

remote viper
#

Okay, thanks. It's annoying.

stuck coral
#

Try platformIO if you dont like it, way better

remote viper
#

Yeah, I started to switch to VSCode but haven't gotten there yet.

#

blah blah missing library path or some nonsence

remote viper
#

Aaah, yes... Now I remember now why I'm in management!

pulsar junco
#

interpersonal skills ๐Ÿ˜‰

remote viper
#

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

remote viper
#

The code was outside of the loop so only declarations work.

pulsar junco
#

does it work in void setup?

stuck coral
#

Uses a lot more memory

#

And is dynamic allocation

remote viper
#

@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.

stuck coral
#

Lol, okay ๐Ÿ˜œ come back with any questions

remote viper
#

More meaningful than "why do all the examples work but none of my code does?"

night jasper
#

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!

pulsar junco
#

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?

gilded swift
#

Yuppers

pulsar junco
#

I think the trinket and the qt are similar in size

gilded swift
#

Qt Py is slightly smaller

pulsar junco
#

plus it's got that nice stemma port

gilded swift
#

Yep ๐Ÿ™‚

#

Rev B for the LiPo power pack will be BMS for better long term battery life

night jasper
#

@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?

gilded swift
#

@night jasper not necessarily

pulsar junco
remote viper
#
gilded swift
remote viper
#

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

gilded swift
#

I just ordered another Qt Py to use for testing some new SPI Flash Iโ€™m adding support for in Circuitpython

#

๐Ÿ™‚

pulsar junco
#

+1 for open source development!

gilded swift
#

Also, if you want to use oled on qtpy, you need SPI Flash

remote viper
#

$6 is very inexpensive

pulsar junco
#

even in arduino?

gilded swift
#

Well, maybe not Arduino

night jasper
#

@gilded swift @pulsar junco Oh I see now, I'd use the backpack with the Qt Py. That makes more sense to me. Thanks!

gilded swift
#

Iโ€™m not sure how big the Arduino library is for oleds

pulsar junco
#

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

gilded swift
#

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 ๐Ÿ™‚

night jasper
#

@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!

remote viper
#

That OLED works via I2C w/CP

pulsar junco
#

It's grayscale tho ๐Ÿ˜ฆ

remote viper
#

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.

night jasper
#

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.

pulsar junco
#

Oh right! That's a cool project

gilded swift
#

I donโ€™t think there are color oled for i2c

pulsar junco
#

I couldn't find any

gilded swift
#

All SPI it appears

pulsar junco
#

You just need another QT PY to run your time machine and go back to when B&W was normal

remote viper
gilded swift
#

But that makes sense since the data frame for a color oled would be much larger than i2c allows

remote viper
#

That's probably the better choice, then.... It's SPI so you'd need to solder it up.

gilded swift
#

Yeah

#

Iโ€™m considering making a 6-pin quick SPI standard

#

Using a 6-pin JST connector

remote viper
#

A lot bigger power budget than the OLED tho, but I couldn't say how much.

night jasper
#

@gilded swift That would be sweet!

pulsar junco
#

that locket would be a cool project for a PCB to mount the QT + power pack and the display on either side

remote viper
#

eInk could be an option if you picked the colors wisely...

#

And then you'd have battery life for days.

night jasper
#

@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!

pulsar junco
pulsar junco
remote viper
pulsar junco
#

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

night jasper
pulsar junco
#

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

remote viper
#

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.

pulsar junco
#

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?

remote viper
night jasper
remote viper
#

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.

pulsar junco
#

I think the QT is a great choice for this

pulsar junco
remote viper
#

It switched because of proximity. It dimmed because my hand was between the overhead light and the sensor.

pulsar junco
#

ah right they have an IR LED alongside the diode or something right?

night jasper
remote viper
#

@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.

night jasper
pulsar junco
#

It also has the same chip as the qt and trinket m0

remote viper
#

they've got one with bluetooth, also.. But yeah, buttons, neopixels, all sorts of handy stuff built in.

night jasper
#

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.

remote viper
#

Right... So minimal code changes necessary.

night jasper
#

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.

remote viper
#

@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?

stuck coral
#

Right, kPath

remote viper
#

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);
}
stuck coral
#

Oh lol, than no sorry

#

strncat(dest, src, sizeof(dest)-1);

#

You are just telling it what the MAX size the string can be

pulsar junco
#

does strncat reallocate mem then?

stuck coral
pulsar junco
#

or does your dest have to be big enough?

stuck coral
#

Has to be big enough

pulsar junco
#

ah that's why it's safer correct?

stuck coral
#

If you want dynamic allocation, use string objects and youll regret it later. Yes

remote viper
#

But strncat has functionality for only copying a specific number of characters

#

That's why it's safer

stuck coral
#

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()

remote viper
#

Ah, yes. Undefined if the dest array is not large enough to append the contents of src.

stuck coral
#

Not undefined, it returns the same size as the array from its return value

#

Undefined is bad

pulsar junco
#

strcat is undefined that scenario right

remote viper
#

Ah, okay, okay.. I see what you're doing there with dest -1

stuck coral
#

Null character, but if you add a check to see if you overran the buffer, than just use sizeof()

remote viper
#

Ensuring that no matter how big src is it's not going to max out dest

stuck coral
#

Right

remote viper
#

well, overflow, technically.

stuck coral
#

Yep

remote viper
#

BUT!!

#

It's ADDING src to dest so you're not taking into account what's already in there are you?

stuck coral
#
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

remote viper
#

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"?

stuck coral
#

What board?

remote viper
#

I can get to the MATRIXBOOT by doubleclicking reset

stuck coral
#

There you go

remote viper
#

Matrix Portal

stuck coral
#

Thats correct

remote viper
#

Just reload it.. Okay, makes sense

#

oh, wow. it still has my circuit python stuff on there, lol

remote viper
#

Hehe... Wife said it's time to stop and come to bed.

#

What she says goes... Adios folks!

#

Thanks for all the help!

stuck coral
#

Remember its there if you ever need to store some data

deep hazel
#

hmm... is ~1.2ms per-character about normal for an M0 drawing to a screen using the Adafruit GFX library?

obtuse spruce
#

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?

deep hazel
#

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

obtuse spruce
#

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.

deep hazel
#

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

obtuse spruce
#

hrm... well.... 160x80x16 = ~205kbits = 6.5ms to transfer at 32mHz

deep hazel
#

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

obtuse spruce
#

er- doesn't GFX have a full in memory display buffer?

deep hazel
#

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....

obtuse spruce
#

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

deep hazel
#

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?

obtuse spruce
#

as it -- will it "expand" when bitblt'd? I'm not sure ... I can go look

deep hazel
#

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

obtuse spruce
#

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

deep hazel
#

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

obtuse spruce
#

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.

deep hazel
#

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

obtuse spruce
#

and... surrounding the block with startwrite() and endWrite() on your own?

deep hazel
#

yeah

obtuse spruce
#

That is exactly what the drawBitmap functions do - so just use them from your own 8x8 font...

#

or rather - test using them

deep hazel
#

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

obtuse spruce
#

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

deep hazel
#

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

pine bramble
#

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?

leaden walrus
#

don't think so. unfortunately that's a windows feature.

spice plume
#

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?

shrewd wyvern
#

I think the issue is more about where are you declaring the function

spice plume
#

I am declaring it after the loop function

shrewd wyvern
#

and call it in the loop function

spice plume
#

i am calling it in the loop and setup functions

shrewd wyvern
#

You need to declare it before setup() and loop()

spice plume
#

ok, thankyou

shrewd wyvern
#

I think that is the issue but try it :p

spice plume
#

it was working fine earlier being defined after the loop, but I will give it a try

pine bramble
#

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

lost kraken
woven mica
lost kraken
#

thank you, kind sir

leaden walrus
#

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)

shell palm
#

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

shell palm
#

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.

pine bramble
#

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?

balmy spade
#

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

Adafruit Learning System

This dev board is so big, it's not named after a Metro train, it's a whole freakin' station!

humble folio
#

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`?

gilded swift
#

@humble folio you could use a shift register

#

Parallel in serial out

#

Tie the output to the input pin of the microcontroller

sour tide
#

@balmy spade the offset is 2k on samd21 and 8k on samd51 iirc

balmy spade
# sour tide <@!784682792335966249> 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

Adafruit Learning System

The first Bluefruit Feather with USB and CircuitPython support

sour tide
#

ah, then I'm wrong ๐Ÿ™‚

balmy spade
#

@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.

stable forge
#

@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.

stuck coral
#

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)

steep robin
#

Has anyone used the DotStar library with an ATTINY1606 or another x06 MCU?

#

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

#

The sketch compiles fine for Uno

stuck coral
#

@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

steep robin
#

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!

steep robin
vagrant tree
#

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 -.-

balmy spade
#

@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?

cedar mountain
#

@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

vagrant tree
#

@cedar mountain Thanks a lot for the hint, will give it a check ๐Ÿ˜‰

stable forge
# balmy spade <@329766224093249548> My naive assumption was that as long as I adjust the linke...

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 ๐Ÿ™‚

balmy spade
stable forge
#

@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

balmy spade
buoyant spade
#

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

cedar mountain
#

What do you mean by "frequency", I guess?

buoyant spade
#

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

cedar mountain
#

(Sorry, I was looking at Timer0 rather than Timer1, hang on.)

buoyant spade
#

dw, i apreciate the help!

cedar mountain
#

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.

buoyant spade
#

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```
cedar mountain
#

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.

buoyant spade
#

btw, is there a text channel which i can specifically ask questions about microcontrollers? dont wanna mess up the structure of this server.

cedar mountain
#

#help-with-projects is the usual catch-all channel for technical questions that don't fit into a particular defined topic.

buoyant spade
#

okay, i will continue there if that's okay for you?

pine bramble
#

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?

obtuse spruce
#

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?

twin ginkgo
#

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?

reef ravine
#

a clock right?

twin ginkgo
#

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

reef ravine
#

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

twin ginkgo
#

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

reef ravine
#

a good idea

twin ginkgo
#

It will be easier to read when its done

reef ravine
#

eventually make it into more of a clock face?

twin ginkgo
#

No not really

#

I can give you an idea in a sec

#

thats the idea

reef ravine
#

ok, looks good

#

and you seem to know your way around a breadboard ๐Ÿ™‚

twin ginkgo
#

yeah i can connect but scripting is the issue

reef ravine
#

my advice is to break the problem down into smaller chunks first

twin ginkgo
#

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

reef ravine
#

that's the menu system, one chunk

twin ginkgo
#

and if the state is in that it would stop the while loop and run time change script

reef ravine
#

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?

twin ginkgo
#

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

reef ravine
#

rtc batteries are usually good for 5 - 10 years, but having buttons to set the time is nice

twin ginkgo
#

so for the button state i was thinking of something like setup = 0

#

for button count 0 would be clock running state

reef ravine
#

so one chunk is detecting button presses and keeping a count of them

pine bramble
#

@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 ๐Ÿ™‚

twin ginkgo
#

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

reef ravine
#

ok good luck!

twin ginkgo
#

thanks

earnest zenith
#

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.

Code: https://github.com/juanino/drybot

โ–ถ Play video
#

thanks so much!

#

(it was a while ago). github code is in video description

balmy spade
stable forge
wooden wagon
#

What is the number attached to a potentiometer

#

10k 100k etc

versed sinew
#

That's the maximum resistance @wooden wagon

wooden wagon
#

So you may need more voltage to get a reading or what?

versed sinew
#

Normally you'd have the potentiometer input at a fixed voltage and measure the output voltage to determine the resistance of the pot

wooden wagon
#

So does it really matter if 10k or 100k? I donโ€™t really get that part

versed sinew
#

Well what are you actually using the pot for? Are you trying to work out its angle, for instance?

wooden wagon
#

Iโ€™m reading the analog signal and use the value for a delay

north stream
#

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?

wooden wagon
#

Yea

#

It goes from 0 to 1024

north stream
#

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.

wooden wagon
#

Thanks

fierce heron
#

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

arctic pelican
#

Can you share the code with us @fierce heron ?

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--;

}

}

arctic pelican
#

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

fierce heron
#

thank you, i will try that now

#

hmm, it doesnt seem to be like the video

unborn frost
#

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

steep robin
#

Feel free to PM me instead of talking through it all here.

sturdy bobcat
#

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.

stuck coral
steep robin
#

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!

ebon reef
#

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

north stream
#

What do you intend to happen when the value is equal to the threshold?

ebon reef
#

LED displays the color and stays on until the the value dips below the threshold

north stream
#

So greater than is white, equal is color, less than is black?

ebon reef
#

Er sorry, Greater or equal to is white, less than is black

north stream
#

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();
ebon reef
#

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

north stream
#

There's an extra semicolon after CRGB:Black

elder hare
#

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?

north stream
#

Depends somewhat on the length of the strips. But more capacitance is rarely bad.

elder hare
#

i ordered 100 1000 ยตF, 6.3V capacitor so why not add 1 on each strip xD

#

even tho they are not THAT long

ebon reef
#

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.
north stream
#

Oh, I goofed, the colons should be double colons

twin ginkgo
#

so i have this buttonState = digitalRead(mcp6.pinMode(0, INPUT)); under void loop but i get invalid use of void expression?

woven mica
twin ginkgo
#

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;
  }
}
shrewd wyvern
#

of all the libraries for rotary encoders do you guys know one that does not use external interrupts and support button click

woven mica
#

@twin ginkgo use ```
buttonState = mcp. digitalRead(0);

twin ginkgo
#

in the void loop?

woven mica
#

yeah

twin ginkgo
#

ok thanks

twin ginkgo
#

does anyone know how to script an RTC?

north stream
#

You can basically do three things with an RTC: set it, read the current time, and get an alarm

twin ginkgo
#

i just woundering how to do the set time

leaden walrus
ebon reef
#

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.

sharp turret
#

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)

elder hare
#

๐Ÿ˜ฆ 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 :/

pine bramble
#

Have you tried checking your wifi credentials?

elder hare
#

yupp!

#

even tested the same code on another ESP32 and it worked

hallow fog
#

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 ?

vivid rock
#

there are 26 000 people in this discord. Do you really want to ping all of them?

odd fjord
#

Fortunately that tag is disabled but it is still extremely rude to use it.

slow nebula
#

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)

safe shell
#

sending data over serial/uart is relatively easy. another option is to use an outboard ADC module on the Weemos, probably I2C

vivid rock
#

@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

slow nebula
vivid rock
#

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

slow nebula
wooden wagon
#

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?

pulsar junco
#

Are you constrained to just the board?

wooden wagon
#

yea, it needs to be tiny. also its the only one i have right now

pulsar junco
#

You should be able to use common ground for all of them

#

so that's 7 fewer pins

wooden wagon
#

hmmm without getting into too much detail, thats not an option for this setup

#

each one needs its own 2 pins for in/out

pulsar junco
#

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

wooden wagon
#

i only count 8 io

#

sorry, 16

#

can tx and rx be use as digital io?

pulsar junco
wooden wagon
#

aesome thanks

#

i can stick an led on tx/rx then use a analog pin for the pot

pulsar junco
#

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?

wooden wagon
#

yes

pulsar junco
#

that's quite a constraint, best of luck!

wooden wagon
#

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

pulsar junco
#

Ah got it

#

I remember this project now, very cool

wooden wagon
#

i guess thats kind of a shift register right?

pulsar junco
#

I think if you code it like one it is

wooden wagon
#

im having trouble flashing my code to this board

#

i dont see a "pro micro" in this board menu

pulsar junco
flint smelt
#

@lethal wigeon I don't suppose you could help me with a nRF52840 systemOff issue, could you?

lavish jacinth
#

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??

stuck coral
#

@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)

elder hare
#
(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?

verbal cloak
#

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

wooden wagon
#

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

fierce plank
# wooden wagon Hi Iโ€™m working on making a DIY led screen (8x8). The LED are wired in a matrix, ...

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

wooden wagon
#

@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?

north stream
#

@verbal cloak The CD4017 will run on a range of voltages, but I can't read the other chip's part number

north stream
#

A 555 will also run on a range of voltages

fierce plank
wooden wagon
#

What is a port in this sense?

#

Right now I just have it like pins

#

In and out pins for each row/col

fierce plank
#

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.

verbal cloak
north stream
#

That's a shame.

flint smelt
#

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?

north stream
#

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.

flint smelt
#

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?

north stream
#

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.

sturdy bobcat
#

So would you say that the Nordic chips have been, at least for you, nRFed?

pine bramble
#

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()'
flint smelt
#

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

pine bramble
#

oh that's a typo

#

haha ๐Ÿ™‚

#

excellent catch!

#

This is why I miss pair programming

flint smelt
#

I hear ya!

pine bramble
#

If that's all it is.... *grumble

#

wow

#

i was that close. dang. the circles i went through

#

๐Ÿคทโ€โ™€๏ธ

flint smelt
#

Story of my life ๐Ÿคฃ

pine bramble
#

what's your github user, i want to give you credit!

flint smelt
#

Aw thanks, I'm @dense flumepeden ๐Ÿ˜Š

pine bramble
#

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

flint smelt
#

Nice!

pine bramble
#

Ok, I'm going to get back it my real job too.

#

Thanks again!

#

be my wingman anytime.

grand knot
#

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 ๐Ÿ™‚

dull bison
#

'''

#

how do you post code snippets

pulsar junco
#

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

vivid rock
#

@grand knot check this example:

grand knot
#

Thank you @vivid rock That makes sense, lets see if I can get all my ==,, in the right places. Cheers for the pointer

vivid rock
#

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); 
}
grand knot
#

You sir are a star!

vivid rock
#

you are welcome ๐Ÿ™‚

rough torrent
#

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 ๐Ÿ™‚ )

flint smelt
#

The Clue doesn't have a charging circuit?

wooden wagon
#

what is RAW and VCC?

reef ravine
#

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

wooden wagon
#

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

reef ravine
#

it comes from the USB's 5v

unborn frost
#

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

reef ravine
#

@unborn frost is IR a possibility? Else the nRF24 might be an RF solution.

tender wharf
#

@unborn frost Bluetooth Low Energy?

stuck coral
#

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

flint smelt
#

Does anyone have experience with nRF52840 low power modes? The systemOff function in the nRF52 BSP doesn't work for me.

shadow zenith
#

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.

flint smelt
pine bramble
#

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?

flint smelt
#

@pine bramble I usually don't worry about it lol

pine bramble
#

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.

flint smelt
#

๐Ÿคฃ

pine bramble
#

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.

exotic sphinx
#

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...

flint smelt
#

You're not missing much, I don't post on twitter much anymore ๐Ÿ˜‚

paper mist
#

quick question for debugging something, how do i set a pin so it is constantly low?