#help-with-arduino

1 messages ยท Page 74 of 1

lone ferry
#

What is the CHSV() function anyway?

marsh rock
#

basically you are just minusing your delta from the max delta

#

so it will be reversed

lone ferry
#

@marsh rock You need to put ` around your code or else Discord messes it up.

marsh rock
#

ahhh thats why

elder hare
#

so then i need to declare 2 new variables NUM_ROWS2 and NUM_COLS2

marsh rock
#

no thats discord messing up my code

#

hang on ill post it properly

#

int delta = (abs(NUM_ROWS*2) + abs(NUM_COLS*2))-(abs(NUM_ROWS - row * 2) + abs(NUM_COLS - col * 2));

elder hare
#

that code inverted the first one, now the color starts from center and fades out to the edge

marsh rock
#

oh sorry i didnt read your whole message

#

i thought you wanted it reversed lol not left to right

lone ferry
#

@elder hare What does CHSV do?

marsh rock
#

int delta = abs(NUM_COLS - col * 2);

elder hare
#

HSV pixel (hue, saturation, value (aka brightness))

#

@lone ferry

lone ferry
#

Oh OK. What are the minimum and maximum values you want to use for hue?

elder hare
#

@marsh rock so close! what's happening is it split the "screen" in two so the colors come from both sides and into center

lone ferry
#

I guess 0-15

#

But you already have logic for this, @elder hare . In your XY() function.

elder hare
#

yes ๐Ÿ™‚

lone ferry
#

leds[XY(col, row)] = CHSV(...)

marsh rock
#

oh, thats cause when col * 2 becomes greater than NUM_COLS (half way) the abs will force the negative number to be positive so it will just add up again half way across

#

but yea its kinda hard to know exactly what delta needs to be clamped at since i dunno what CHSV does with it

#

but you could try

#

int delta = NUM_COLS-col;

lone ferry
#

Earlier I suggested int delta = col; which should work, when combined with XY().

#

int delta = NUM_COLS -1 - col; should also work, it just goes the other way then.

marsh rock
#

yea basically the reverse

elder hare
#

both of them gave me the "every second line reversed" (i gotta say, going from a simple 1 line neopixel strip to a matrix is hard)

lone ferry
#

What is your current code?

marsh rock
#

int delta = col * 2

#

seeing as how the original was scaled by 2

elder hare
lone ferry
#

Did you try leds[XY(col, row)] = CHSV(...) ?

elder hare
#

with int delta = col; ?

#

that worked @lone ferry ! ๐Ÿ™‚

lone ferry
#

I know, that's why I suggested it earlier.

elder hare
#

now there is just the matter of the flickering -.-

#

i have a 500 resistor on the data line closest to the "first neopixel"

lone ferry
#

In what way does it flicker?

#

You'd probably need to record a video to show this.

elder hare
#

i fixed the flicker

marsh rock
#

did you turn off interrupts

elder hare
#

i soldered 5v from the PSU and unplugged the USB powering the esp8266 ๐Ÿ™‚ works flawless

marsh rock
#

oh nice

#

do you have a cap between the + and - ?

#

if id have to guess, id say the usb power wasn't smooth enough

lunar depot
#

I have successfully got the Adafruit "sevenseg" demo running on my 1.2" 4-digit 7-segment display on an Arduino UNO. I am trying to get the same demo running on an ESP32 D32 Pro. ESP32 is 3.3V only so I have a separate 5V VCC running to the + on the I2C channel and 3.3V from the ESP32 to IO pin on 7seg. I have the SDA/SCL pins connected correctly. I am getting nothing from the display. I have GND on 7 seg connected to the 5V power GND pin. Does the ESP32 GND need to be connected to the same GND? Do I have to do something on the ESP to set GPIO21/GPIO22 to SDA/SCL or should they just work as I2C ports by default?

#

I have it:

C -> SCL
+ -> 5v
- -> GND
IO -> 3.3v```
cedar mountain
#

Yes, all the grounds need to be connected, since all the other voltages are relative to that.

lunar depot
#

Can I share the same GND?

#

I still get nothing on the display

cedar mountain
#

I'm a little worried about the 3.3V logic, since the I2C bus is pulled up to 5V on the backpack.

#

Does the 1.2" backpack actually have an IO pin like you pasted above?

lunar depot
#

Yes it does

cedar mountain
#

Oh, my bad, I was looking at the 1.2" 8x8.

lunar depot
cedar mountain
#

Have you tried with only one display connected, to eliminate possibilities of address-pin problems?

lunar depot
#

There is no problem with address as I have them working independently using my UNO. I have the left one set to 0x70 and the right one set to 0x71

cedar mountain
#

Any error messages from the code?

lunar depot
#

No errors

#

And I get debug output from the Serial Monitor

cedar mountain
#

Double-check the wiring to 21/22... it looks like you might have the purple SCL wire going to SDA on 21.

north stream
#

If you run an i2c scanner on the ESP, does it see the two devices?

lunar depot
#

Where can I find an i2c scanner?

north stream
lunar depot
#

@cedar mountain You're right the 21/22 pins were the wrong way around. Unfortunately swapping them still doesn't light up the display

#

Thanks @north stream I'll take a look at that

cedar mountain
#

The lack of errors is annoying, since it indicates the software isn't checking for anything. So, yeah, the scanner would be a good step to verify communications.

obtuse spruce
#

@lunar depot - can you double check the power (+/-) line connections on the breadboard - it is probably just the image paralax, but the ones on the right look, backward?!? and I can't really tell on the left

#

either that or perhaps the Adafruit write up lists the pins in the wrong order?

lunar depot
#
done```
#

It's not finding 0x71 although I could address it on the UNO

north stream
#

That's distinctly odd.

lunar depot
#

Something is unreliable. I tried a different breadboard. Maybe some of my jumpers are garbage

No I2C devices found

Scanning...
I2C device found at address 0x71  !
done

Scanning...
I2C device found at address 0x70  !
I2C device found at address 0x71  !
done

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found

Scanning...
No I2C devices found```
north stream
#

Intermittent connections are frustrating

marsh rock
#

if its breadboard or EF wackiness, it sometimes helps for me to connect my IO lines to ground with a high resistance, like 500k when im proto boarding

lunar depot
#

It was just crappy breadboards. I changed to my good ones and it's all working now ๐Ÿ™‚

#

Never using crap breadboards again!

lunar depot
#

So everything is working great now, thanks to everyone who offered help!

#

Only have one minor issue now. I can light up the middle colon using matrix.drawColon(true). But how do I light up the front one?

north stream
#

I don't know offhand, but I'd look at the library to see what drawColon() does, and if there's something similar for the other segments/dots.

lunar depot
#

Just discovered that matrix.writeDigitRaw(2, 0x0E); lights up both

#
0x04 - left colon - lower dot
0x08 - left colon - upper dot
0x10 - decimal point```
gilded swift
#

Wow nice!

lunar depot
#

Digital clock that displays milliseconds

#

When you boot up it connects to a time server to sync time

#

I am going to be adding a 32Khz crystal for keeping accurate time

#

Then 3d print a box for it

#

I'll be making all the code and files available on Github

obtuse spruce
#

Hmmmm.... I could use something like that to display timecode when I'm video editing....

lunar depot
#

@obtuse spruce code to display a timecode on two Adafruit 1.2" 4-digit 7-segment displays looks like this (start with the Adafruit "sevenseg" example):

{
  int tm_cs  = milliseconds / 10;
  matrix1.writeDigitNum(0, timeInfo->tm_hour / 10, true);
  matrix1.writeDigitNum(1, timeInfo->tm_hour % 10, true);
  matrix1.writeDigitRaw(2, 0x02);
  matrix1.writeDigitNum(3, timeInfo->tm_min / 10, true);
  matrix1.writeDigitNum(4, timeInfo->tm_min % 10, true);

  matrix2.writeDigitNum(0, timeInfo->tm_sec / 10, true);
  matrix2.writeDigitNum(1, timeInfo->tm_sec % 10, true);
  matrix2.writeDigitRaw(2, 0x0E);
  matrix2.writeDigitNum(3, tm_cs / 10, true);
  matrix2.writeDigitNum(4, tm_cs % 10, true);

  matrix1.writeDisplay();
  matrix2.writeDisplay();
}```
mellow flax
#
    Resistance = (1023 / ADCvalue) - 1;
    //Resistance = SERIESRESISTOR / Resistance;
#

what is this turning the analog value into?

obtuse spruce
#

some code notes:

int ms = millisconeds / 10 | 0;

The | 0 isn't doing anything. There is no need for it in C++ (looks like it was copied from Javascript).
The name ms is a bit misleading... perhaps cs for centiseconds

Since hours, minutes, seconds, and centiseconds are all less than 100, there is no need to '% 10' after the division by 10. Again, in C++, since these values are all some form of integer, the division will be an integer, and in these cases, less than 10.

lunar depot
#

@obtuse spruce You're right.. there is no remainder from an integer division. I lazily copied it from the Adafruit example. Anyway I've updated it now. Thanks for your input!

obtuse spruce
#

@mellow flax - it might be more clear if you think of it as 1023 * (1/ADCvalue) - 1?? You can really do that because this is all integer math... but it is equivalent to that.

#

@lunar depot Just call me "Dr. Code Hygene"!

#

And look how nice and clear that code looks now!

lunar depot
#

@obtuse spruce The joke is I'm normally just as pedantic but I was so caught up with my hardware issues I didn't even look much into it. But yeah it looks much cleaner now thanks again!

#

It looks great on these 7-segment displays too. They're super bright (brightness can be set between 0-15). I have it set to 4 and it's still quite bright.

mellow flax
#

I understand now

#

I wasn't fully understanding how the analog to digital conversion worked

lunar depot
mellow flax
#

I feel like that's a crazy amount of data lost during analog to digital conversion..

#

ADC values are always whole numbers right?

#

I'm sorry if this is a really dumb question, I don't even own an Arduino yet.

#

waiting for it to be delivered

#

I'm guessing the only way to avoid this would be to buy a thermistor with a less steep curve

north stream
#

Or add signal conditioning circuitry to match the range of interest to your ADC.

obtuse goblet
#

Uh Im in a class going over the basics of mircocontrollers, and I cant quite seem to get the homework right about Oms Voltages and Currents. Can Anyone Help me?

north stream
#

Probably, but you'll need to explain how far you've gotten and what you're unclear on.

obtuse goblet
#

it should work now

#

just started class today and its not really making sense

north stream
#

So, how far have you gotten and what are you unclear on?

obtuse goblet
#

so

#

it prompts

#

Draw the circuit for a 12V battery with a 2.0 Ohm resistor connected across it.

Draw the circuit in which the one above is altered to have a second resistor (of 4.0 Ohms) in series with R1.

north stream
#

Okay. Did the teacher explain series resistors?

obtuse goblet
#

Our teacher is horrible

#

Im afraid not

north stream
#

Components in series are hooked end to end, so all the electricity flows through all of them.

obtuse goblet
#

ok

north stream
obtuse goblet
#

okok

#

so

#

After that, it asks me the equivalent Resistor, in which I answered 6ohms

north stream
#

That seems right to me, resistors in series have their resistances added together.

obtuse goblet
#

And so how do I find V1, V2, I1 and I2?

#

that doesnt make sense to me

#

I know that V= IR

#

and the derivatives of that equation

#

and P=vi

north stream
#

Another thing about series components is that all the current flows through all of them.

#

So you've figured out the equivalent resistor, you can use that to calculate current, using the battery voltage.

obtuse goblet
#

so its 12V= IR

north stream
#

Correct.

obtuse goblet
#

and then just plug in the resistances?

north stream
#

You plug in that equivalent resistance you calculated earlier

obtuse goblet
#

for both of them?

#

even if its asking for the individual V1 and V2?

north stream
#

Let's not worry about V1 and V2 yet, let's just figure out I to start with

obtuse goblet
#

okay, overall, its just just 2 and 6 right?

#

2*6= 12 so it makes sense reverse as well

north stream
#

It pays to be clear: 2 what, 6 what, and 12 what?

obtuse goblet
#

12v, 2A, 6ohms

north stream
#

Ah, much better.

#

Since all the current flows through all the series elements, you can deduce I1 and I2 fairly easily.

obtuse goblet
#

Both being 2A Correct?

north stream
#

Bingo, right.

#

Now there are two ways to calculate V1 and V2. One is to use V=IR again.

#

For each resistor, you know R and I, so you can calculate V.

obtuse goblet
#

V1 = 4

#

and V2 = 8

#

and it makes sense because adding them together makes 12

#

the total current right?

left grotto
north stream
#

Total voltage, that is

obtuse goblet
#

right

north stream
#

All that looks good to me. However, there's another way to calculate V1 and V2, so you can do that too, as another cross-check.

#

Resistors in series are known as "voltage dividers", and the voltage divides proportionally by the resistance.

#

The voltage across each resistor is proportional to its resistance divided by the total resistance.

obtuse goblet
#

so because the proportion is 2:1, the remaining voltage would distribute as so?

#

not remaining

#

but all

north stream
#

Right. Or mathmatically, V1 = V * (R1 / (R1 + R2))

obtuse goblet
#

okay

#

finally

#

its asking me to do the same thing

#

but with series

#

sorry

#

not series

#

Parallel

north stream
#

Parallel works differently. In series, all the components get all the current, but the voltage divides. In parallel, all the components get all the voltage, but the current divides.

obtuse goblet
north stream
obtuse goblet
#

ooo

#

i remember seing something on khan academy on this

#

so the R123 would be like 1ohm

north stream
#

That's a good resource

obtuse goblet
#

because its [1/2 + 1/4 + 1/4]^-1

#

which is just [1/1]^-1

north stream
#

Looks right to me.

#

In this case, V1, V2, and V3 are the easy ones to calculate

obtuse goblet
#

All the same right

#

wait

#

no

north stream
#

Yes: they're all connected to the battery

obtuse goblet
#

oh

#

okay

#

so V1,V2,V3 = 12V then?

north stream
#

Right. Then you can use Ohm's law to calculate the individual resistor currents.

obtuse goblet
#

so 6A, 3A, and 3A.

north stream
#

Also looks right. Do you know how to calculate the aggregate current from those?

#

(hint: it's not hard)

obtuse goblet
#

no clue what that is

north stream
#

The total current coming from the battery

obtuse goblet
#

12V

north stream
#

That's the voltage. You have the current through each resistor, all that is being supplied by the battery. So how do you get the total current from the individual currents?

obtuse goblet
#

Add all the current together

#

so 12Amps?

north stream
#

Yes and yes.

#

For a check, since you calculated the equivalent resistance earlier, you can use that to calculate the current as well.

obtuse goblet
#

You have singlhandley in an hour taught me more than my Professor in 2 days in 1 hour.

#

You are a good man

north stream
#

I had teachers that seemed to make simple stuff confusing, I really try to avoid that, and I appreciate the compliment, thank you.

#

Now for @left grotto 's issue

left grotto
#

hahahah thanks

north stream
#

I see the schematic, looks like an Arduino, IR receiver, motor driver, and two motors. You say "the IR doesn't give response", but I'm unclear on what that means, unless I'm misunderstanding something (likely)

left grotto
#

after that image i was pressing buttons of the control

north stream
#

I wonder if it's not getting signal, or the sketch has crashed

#

More specifically, I suspect the motors are introducing noise, spikes, and/or dips in the power supply, which could be causing the Arduino's CPU to glitch.

#

In general, electrically noisy things (like motors) shouldn't share a power supply with digital logic. This is one of the reasons the L293 has two Vcc pins, one for logic and one for the motor.

left grotto
#

the motors make a noise but if i touch them so they start rotating, the noise stops

north stream
#

Interesting. That would seem to indicate the voltage is lower than the motors are designed for.

left grotto
#

if i connect a battery to the breadboard?

north stream
#

Not quite. You do want to connect the negative side of the battery to the 0V reference of everything else, but you do not want to connect the positive side of the battery to +5V

#

Basically, you only want to connect the positive side of the battery to Vcc2 on the L293 chip (pin 8), and disconnect pin 8 from everything else

left grotto
north stream
#

Looks right to me.

left grotto
#

didn't work, motors don't turn on

north stream
#

Hmm, do you know the ratings of the motors?

left grotto
#

I think there are 3v dc motors

north stream
#

Hmm, 9V is high for those, I suspect they draw a fair amount of current, I wonder if it's more than the 9V battery can supply.

left grotto
#

I think you are rigth. I connected arduino only to the battery and motors didn't turn on, so then connected the usb and they did

#

but it keep happening that after turning on the motors by the IR, it doesn't receive any signal

north stream
#

I suspect the IR receiver itself is getting the signal, but the Arduino has crashed and no longer responding to it. I would try adding some power supply decoupling/filtering to isolate the logic supply from the motor supply. If you have some capacitors, low value resistors, or diodes, it's worth trying a few configurations.

left grotto
#

i have, but am really new to that, didn't know exactly how

deep tapir
#

I just found out that ultrasonic sensors dont work on non-perpendicular surfaces

#

would an infarred sensor work with nonperpendicular surfaces

left grotto
#

I think that's not the issue

deep tapir
#

like its supposed to be the same thing before and after

#

but it isnt.

#

is this a problem with the serial?

#

basically trying to run two roboclaws at once

errant geode
#

Can someone help me with ttgo watch and displaying colors? I want to load bmp, but it displays wrong colors. So i decide to test it with manually entering r, g, b values - but it still display wrong colors. Here is my code:```cpp
for(int i = 0; i < ImageHeight; i++)
{
for(int j = 0; j < ImageWidth; j++)
{
LcdBuffer[j] = SmartWatch->tft->color565(255, 0, 255);
}

SmartWatch->tft->setAddrWindow(x, (ImageHeight-i)+(y-1), ImageWidth, 1);
SmartWatch->tft->pushPixels(LcdBuffer, ImageWidth);

}```Normally i read r, g, b values from bpm, but for testing i replaced it with 255, 0, 255 (this should be pink / magenta), but when i upload code to my watch it displays this:

lone ferry
#

What happens when you try (0, 255, 255)? @errant geode

errant geode
#

@lone ferry Now it is yellow.

#

I try to load bmp image and invert colors ( SmartWatch->tft->setSwapBytes(); ) but still there is something wrong:

woven mica
#

it seems like the display uses b, r, g format - magneta should be (255, 255, 0)

lone ferry
#

Indeed

magic needle
#

Hi, I've got a question about my uno. I'm just lighting some LED's, however I'm getting a low voltage from every pin but the first of 3 LEDs (SOS example). All the LEDs work, all on 330 ohm resistors, and in just writing all pints high in the sketch, they work, but in the program the LEDs (2 and 3) are dim hence the low voltage. Thoughts?

lone ferry
#

How many LEDs do you have?

magic needle
#

just one per pin, using 3 pins

errant geode
#

@lone ferry @woven mica I tested all combinations and there is one good - this display is inverted bgr. Now it is working good, thanks for help ๐Ÿ™‚

lone ferry
#

@magic needle How have you connected everything?

magic needle
#

pin# - jumper - led - resistor - gnd

lone ferry
#

Could you post a photo?

magic needle
#

uploading, all resistors are in the same location, I'll post a third with all pins just written high

lone ferry
#

One thing that isn't immediately clear but does seem odd: is the - strip on the right side of the board actually connected to anything?

magic needle
#

sorry, didn't realize I was missing that, yes it is, justjumped the +/- rails years ago, connection is fine, this issue just cropped up and I can't figure out why, hence my quesiton.

lone ferry
#

So the problem is that in the 2nd image the 3rd LED is very dim, but in the third image it works fine?

magic needle
#

third image is just a separate sketch to make them all high for debugging, but the only thing that changes in the SOS sketch is the pin number just changing which LED is blinking the morse code

lone ferry
#

OK, so it looks like your pins and your LEDs work fine. The error must be in your SOS sketch then.

magic needle
#

that's what I thought, but it was copy/paste, change the pin variable

lone ferry
#

Can you share the source code?

magic needle
#

one sec, I think I figured it out, gimme a sec

#

HA! jumped the gun and I thought I had set my pinmodes, missed 2 and 3, makes sense now, but kinda strange that it still has an output when you don't set the pinmodes

north stream
#

There's old support for configuring a pull-up resistor on an input by setting it as an input and writing a high level to it: when I saw the dim LED, I wondered if I should point that out, but you seemed to be asking about something else.

lone ferry
#

There you go, mystery solved. ๐Ÿ™‚

magic needle
#

heh, yeah, sometimes I can talk myself out of the problems. Thanks guys!

deep salmon
#

hey guys, complete noob here and I have a problem that's probably dumb easy. I have a green laser hooked up to my elegoo uno R3 but after 15 seconds the board get hot to the touch, the yellow light starts blinking and the laser starts flickering. Any ideas?

candid topaz
#

i think you need transistor and external power supply for laser

#

can you measure how many amps it uses?

deep salmon
#

Working Current:>200mA

candid topaz
#

arduino max 50mA per pin and total 200mA

#

you need transistor or relay to turn it on ๐Ÿ™‚

deep salmon
#

ahhh, I see. I have a PN2222, will that do the trick?

#

it's going to be a youtube tutorial day, I can feel it already haha

candid topaz
#

IC Collector Current 600 mA

#

i think just connect it to power supply and measure how much current laser uses

elder hare
#

heeeelp :|

line

for (int i = 0; i < NUM_LEDS_PER_STRIP; i++)

error

comparison between signed and unsigned integer expressions [-Wsign-compare]
exotic sphinx
#

@elder hare I think it's saying that you didn't give "NUM_LEDS_PER_STRIP" a value

elder hare
#

i have :S

#

the weird thing is

#

this code works on ESP32 but NOT ESP8266 :S

#
src\MyFastLED.h:253:5:   required from 'MYFASTLED<PIN_OF_LED, NUM_LEDS>::MYFASTLED() [with unsigned int PIN_OF_LED = 22u; unsigned int NUM_LEDS = 19u]'
src\main.cpp:14:19:   required from here
C:\Users\Krist\.platformio\lib\FastLED_ID126/fastpin.h:207:2: error: static assertion failed: Invalid pin specified
*** [.pio\build\esp12e\src\main.cpp.o] Error 1
errant geode
#

Can someone help me with display... again? I have this code:cpp void DrawBmp(String Image, int x, int y) { File BmpImage = SPIFFS.open(Image); BmpImage.seek(0x12); int ImageWidth = BmpImage.read(); BmpImage.seek(0x16); int ImageHeight = BmpImage.read(); BmpImage.seek(0x36); uint8_t SdBuffer[720]; uint16_t LcdBuffer[240]; for(int i = 0; i < ImageHeight; i++) { BmpImage.read(SdBuffer, ImageWidth*3); for(int j = 0; j < ImageWidth; j++) { LcdBuffer[j] = SmartWatch->tft->color565(SdBuffer[(j*3)+2], SdBuffer[(j*3)+1], SdBuffer[j*3]); } SmartWatch->tft->setAddrWindow(x, (ImageHeight-i)+(y-1), ImageWidth, 1); SmartWatch->tft->pushColors(LcdBuffer, ImageWidth); } BmpImage.close(); }And this code works only with images that are 120x120px (my first image, logo) and 48x48px. Others resolutions are glitched, i dont know why? I tried 51x51 (dividable by 3), 54x54 (dividable by 9), even 81x81. Only working resolution i found so far is 48x48 (every image created and saved in microsoft paint, when i change resolution for example from 48 to 50 it glitches, when i switch from 50 back to 48 and upload it again it looks right again). This glitch look like this (clock is the only image with 48x48 resolution):

obtuse spruce
#

@errant geode - The reason is because each line of a BMP file is padded out to a multiple of four bytes. If your image is 51x51, then 51*3 = 153 bytes for the data - is going to be padded with 3 more bytes out to 156.

#

I assume you realize that you are making an assumption about the pixel depth of your images - rather than having the file tell you.... but that is reasonable if you know for sure they alwyas will be. Otherwise, that will, at some point that will bite you.

vivid rock
#

you mean, padded to 156

obtuse spruce
#

er, yes

#

The following addition to your loop should work:

    int rowTail = ImageWidth*3 % 4;
    int rowPadding = rowTail ? 4 - rowTail : 0;

    for(int i = 0; i < ImageHeight; i++)
    {
        ...

        if (rowPadding)
        {
            BmpImage.read(SdBuffer, rowPadding);
        }

    }
errant geode
#

@obtuse spruce Ok, thank you for help, I will try it.

wooden crescent
#

ok.. i've got a weird issue i'm having with a pro micro..

#

i have a sketch that needs to able to operate as standalone, or output to serial if connected..

#

the issue is this: the "while (!Serial) ; loop ONLY succeeds after a flash.. if i just plug the device in after being powered down.. it never succeeds. the only way i can initiate serial communication is to reflash the sketch, and then it works as expected (but also can't operate in standalone mode as it's stuck in the while loop..

obtuse spruce
#

If you want it to be optional, while are you having the while loop be required? Also, just to double check, you are calling Serial.begin() before that while loop, yes?

wooden crescent
#

yes, i'm calling serial.begin() -- it just will not open a connection, unless it has been run from a "warm boot" so to speak

#

i've even added delays and tried to rerun the function if (!Serial)

#

i can get it to run in either standalone or after a flash

#

it just will not open a serial connection in any scenario besides immediate after a flash

#

heck, it won't even reconnect if i pull RST low

obtuse spruce
#

in my core !Serial already calls a function with a delay... but maybe not yours....

wooden crescent
#

maybe it's something about the bootloader i don't understand

#

so.. lets say for instance, i have an external power source.. but need to plug into a PC for datalogging via serial

#

how do i initiate that connection? Serial.begin only works after a flash/upload from what i'm seeing here..

obtuse spruce
#

Wait - are you include a baud value in begin()? Like

Serial.begin(115200);
wooden crescent
#

yes

obtuse spruce
#

k

wooden crescent
#

hang on let me get you a sample sketch illistrating the issue

obtuse spruce
#

No idea - it should work at any point, really

wooden crescent
#

i guess i need someone to confirm that this doesn't work

#

it could be a bad 32u4 (although unlikely) -- i'll test with another

#

but let me bring my sample, to make sure i'm not overlooking something simple..

#

tell me if you see anything that looks wrong there.. that demostrates and explains the issue

#

i mean, maybe i missed something...

obtuse spruce
#

Yeah, inside the whole loop you should have just:

   if (Serial) break;
wooden crescent
#

alright let me try that

obtuse spruce
#

in other words: if serial is up, we can stop waiting and checking.

wooden crescent
#

yeah.. made no difference.. serial only starts after uploading.. if i unplug/replug the device, it never starts (and yes i have serial monitor open and connected to the proper port)

#

let me test it on another 32u4

#

yeah.. same.. it will not initiate the serial connection

obtuse spruce
#

Also... 9600? Usually my IDE picks a higher baud rate

wooden crescent
#

it was just a a safe value.. i mean i doubt that is the issue.. we are just looking for serial at any speed..

#

9600 works after uploading just fine..

#

maybe it's something with the bootloader that it only initiates a serial connection after uploading for debugging?

obtuse spruce
#

It's just that uploading almost certainly uses a faster baud rate - and perhaps after uploading the Serial is left at that speed ... and if your IDE is using 115200, perhaps it works... and then when reset, the rate is reset to 9600... and if that were the case, the serial port won't connect, perhaps.... dunno.... this is Serial over a USB connection, right?

wooden crescent
#

yes, serial over usb

#

^ above is the serial monitor after an upload

obtuse spruce
#

okay - I'm stumped! ๐Ÿ˜ซ

wooden crescent
#

it seems like 9600 isn't an issue

#

yeah me to.. it's caused A LOT of headache here..

#

from debugging interrupts, to debugging and testing i2c devices, to hours of playing with code to narrow it down to this

#

i thought my program was hanging

#

As a matter of fact, I can get it stuck in a state where I can't even upload a new sketch, just by using the while (!Serial) line

#

I have to pull reset low & pray my timing is good to reupload after that

#

so i guess i should file a bug report somewhere?

#

it seems that the serial protocol relies on some control signals that are (mishandled) at a lot of stages between programs & drivers on the PC side.

main olive
#

So when i upload somthing like the code below, it says i have not made a variable, even though i have. Its in the void start because if its made before randomSeed is called, it will just be the smae number everytime. Help? ```void setup(){
Serial.begn(9600);

randomSeed(analogRead(5));

int randomnumber = random(1, 9);
}

void loop(){
Serial.println(randomnumber);
}

wooden crescent
#

so, upon uploading, the arduino IDE sets them properly (as they control RESET as well)

#

@main olive wrong scope.. you defined randomnumber in setup() but are trying to use it in loop

main olive
#

but it wont be affected by randomSeed if its above void setup

wooden crescent
#

int randomnumber;

void setup() {
Serial.begn(9600);

randomSeed(analogRead(5));

randomnumber = random(1, 9);
}

void loop(){
Serial.println(randomnumber);
}

#

sorry that was quick and dirty let me look again

#

no that should work..

#

you are simply defining it as global (in my repost)

#

then initiating it in setup()

#

and reading it in loop()

main olive
#

ah

wooden crescent
#

defining it globabally makes it usable anywhere. but you still have to write to it from inside a function

main olive
#

oh yeah. If i put it in void setup its a local variable and i cant access it outside of setup.

wooden crescent
#

anyway, back to the serial thing.. so the IDE sets those lines, and resets it, leaving the serial port open.. otherwise a cold reset can't initiate the PC side of things, so you don't get a connected serial monitor...

#

maybe some different terminal software would fix this..

#

but it would still only work at the point of calling Serial.begin()

#

@main olive exactly

mighty hazel
#

Ok... weirdly specific problem here. I'm making an Arduino proto-board setup with power and programming built in. I'm trying to figure out where to input power. 5V and USB-5V aren't connected, so if I was to connect to 5V would programming still work?

#

The source I'm using for power is the Adafruit PowerBoost 1000, so it outputs 5.2V.

#

The Arduino, if powered from the USB (as I understand it) would regulate this down, so I couldn't use it as a power source for the breadboard as the voltages wouldn't match.

wooden crescent
#

@obtuse spruce yep.. changing the delay to 15 secs, and then manually reopening the serial monitor upon a cold boot fixes it.. sigh, what a crappy OS/software "design flaw" to work around

mighty hazel
#

Is there any forseeable issue with connecting 5V straight to the breadboard and PowerBoost 1000?

wooden crescent
#

guess i need to to randomly sprinkle some Serial.begin(0's in my code to enable it to be plugged in after the fact

#

and then wait for 500ms or so to see if it had serial initiated

pine bramble
#

I have never typed this, for SAMD21:

Wire.begin();
#

Might be an AVRism.

#

ISTR there was an #ifdef for that.

#

The Adafruit example code should run.

wooden crescent
#

correction.. i don't need to do anything special.. Serial will set once it's ready (about 2 seconds) without a second Serial.begin statement..

#

so, i may just want to add a 5 second delay to allow the user to open a terminal program.. or not output anything until the datalogging process has begun..

pine bramble
#

I could not find the exact repository where the Arduino IDE draws from, for the gcc compiler it uses (wrt SAMD targets, anyway).

#

The version on my hard disk has an include file and I wanted the github repository source for it.

#

/path/to/files/.arduino15/packages/arduino/tools/arm-none-eabi-gcc

#
 $ egrep int64_t stdint-gcc.h 
typedef __INT64_TYPE__ int64_t;
typedef __UINT64_TYPE__ uint64_t;
 $ pwd
/path/to/files/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/lib/gcc/arm-none-eabi/7.2.1/include
#

One of the programs I use (YAFFA-ARM) makes use of these types; I could find no reference to them outside of the compiler itself.

topaz compass
#

Hey folks. I just got a new Feather Huzzah and I'm trying to upload a sketch, but the upload always fails with this rather unhelpful error: Connecting....
A fatal error occurred: Timed out waiting for packet header

obtuse spruce
#

These are very specific to GCC, and I can't imagine that any library should be using them directly.

#

Wait, are you referring to int64_t and friends? Those are part of the C++ standard, and you get by including stdint or stdint.h (your pick...)

#

Looking at the source for YAFFA-ARM, it seems that YAFFA.h isn't self contained: It relies on includes that the includer of YAFFA.h must have included first. YAFFA-ARM.ino doesn't include any standard headers, and indeed won't compile on my system.

#

If, however, you include Arduino.h before you include YAFFA.h things will work, because you get stdint.h indirectly when you include Arduino.h

safe shell
#

@topaz compass Arduino doesn't seem to see the Feather. What's your hardware setup, and can you verify the Port choice in Arduino matches the USB port it's on? Does the PC see the device on the USB port?

topaz compass
#

And yes, I verified the port chosen in Arduino is COM4

pine bramble
#

@obtuse spruce Thanks!

#

YAFFA-ARM is upstream (and it's been so long I don't remember if it compiles with no prep).

https://github.com/wa1tnr/ainsuForth-gen-exp-m4
is my go-to port of YAFFA-ARM. I haven't looked at it in quite a while, as it was more interesting to me before I found an eForth port that ran on an Adafruit target (STM32F405 Express).

#

https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html

#

There was a copy of this in my Arduino IDE tree and I looked at it this morning.

#

All my programs (almost all of 'em anyway) have a blank .ino (or just comments) and (therefore) must

#include <Arduino.h>```  .. in the `.cpp` file(s); otherwise they don't compile.  I had no real idea what is included when that one is. ;)
#

I found (through experimentation) that a directory named ./src is treated as expected.

#

No other name is recognized - haven't figured out where this is implemented.

alpine oasis
#

I have MCP23017 module and nodemcu. I'm trying to use interruptions of MCP to know about buttons clicks, but they just not work. I need help with it.
https://hastebin.com/narecukehu.cpp

safe shell
#

@alpine oasis No Arduino IDE compile errors?

alpine oasis
#

None.

#

Why should they be?

safe shell
#

just making sure

#

You could do a simple code test just to report back the levels of the buttons (without the complexity of the interrupts) to verify wiring and that all the parts in the path function. I see an LED and resistor, so I'm guessing you've checked the button functions all by itself as wired.

alpine oasis
#

I had ticker outputting values from mcp row. Checked that buttons properly connected. After it commented.

#

So buttons work.

#

Resistor and led not connected. Left for debug.

formal python
#

it's possible to compress an arduino code ?

stuck coral
#

Oh that is quite a rabbit hole, practically and easily, no, but there is a lot you can do to conserve memory

#

Self compressing code is actually a thing, you mean in order to execute correct?

formal python
#

I have installed an arduino in my video game controller, but the arduino code i put takes 18% of the space and the bigger the data, the more delay there is

stuck coral
#

That is not correct, but I think I know what you are meaning, bigger applications do not cause a longer "disk" time. I think you might need to look at how your code is laid out, if you put it in a paste bin I can take a look at it

formal python
stuck coral
#

Why is your code like... so tightly written? Nothing really wrong with it but it does make it harder to read

#

Also, which Arduino are you using? Storage space is not your issue, and Im not seeing much in the code that is blocking. And how long does it take to loop through main once?

formal python
#

I use Arduino Nano

stuck coral
#

How long does it take to go through the main loop once? And what is appearing slow to you?

formal python
#

if I only leave the minimum in the arduino, it seems faster to me

stuck coral
#

I dont understand what you mean by that

formal python
#

Like I said before, when my arduino have 18% of data , I felt not faster than if he have 4%

stuck coral
#

The issue is not the code size, but rather the code that is included within that extra 14%. What are you removing/adding from the code

formal python
#

I didn't removing adding from this code

stuck coral
#

What did you do to go from 4% to 16% storage usage?

formal python
#

oh, I delet somes Lines of the code yeah sorry

stuck coral
#

Which lines?

formal python
#

from void perfectangles(){ to void nocode

stuck coral
#

But you are still running controller.read(); gcc = controller.getReport();?

formal python
#

yeah

stuck coral
#

Okay, if so, I think the nano is having an issue keeping up with the math if Im not mistaken

#

Could you tell me how long it takes to execute convertinputs()?

formal python
#

how I can know that ?

stuck coral
#

First you would need to start a serial connection to your computer by adding Serial.begin(115200); in setup so you can see the result. Then you can run within your main loop-

unsigned long s = micros();
convertinputs();
Serial.println(micros-s);
formal python
#

So I plug my arduino in the computeur, then with the software Arduino ? I have to do what ?

stuck coral
#

In the upper right there is a button with a looking glass and when you hover over it the words Serial monitor should appear

formal python
#

true

#

I past this : "Serial.begin(115200);"

#

nothing happen when I sent "Serial.begin(115200);"

stuck coral
#

You need to add that to your code in the setup section

formal python
#

like that?

stuck coral
#

No, that code you need to add to your code within the main loop, that serial monitor will show you whats put in Serial.println(micros-s); when ran

formal python
#

I really don't understand
I plug my arduino nano in my computeur
then I click in the monitor , I can send a line

stuck coral
#

The code is not setup to receive the line, it will print in the box below the output of the Serial.println(); line

formal python
#

yeah but how I add Serial.begin(115200); ?

#

directly in the code ?

stuck coral
#

Put it in the setup function inside the code, yes

formal python
#

I add in the end of the code

stuck coral
#

No, put it in the setup function

formal python
#

ok ok

stuck coral
#

No, in the setup function, like this-

void setup(){
  Serial.begin(115200);
  gcc.origin=0; gcc.errlatch=0; gcc.high1=0; gcc.errstat=0;  //init values
  swang = ang(abs(sw_notch_x_value), abs(sw_notch_y_value)); //calculates angle of SW gate based on user inputted data
  seang = ang(abs(se_notch_x_value), abs(se_notch_y_value)); //calculates angle of SE gate based on user inputted data
}
formal python
#

okay done

#

then ?

stuck coral
#

Awesome, great, then add the other code I gave you to your main loop

formal python
#

we are good right?

stuck coral
#

Yeah, that should work. Go ahead and upload the code, then open the serial monitor, then in the lower right of the serial monitor there is a drop down and select 115200

formal python
#

but nothing happen

stuck coral
#

My bad, forgot the (), please fix that last line in loop Serial.println(micros()-s);

formal python
#

still nothing

stuck coral
#

But the code is still working as ususal?

formal python
#

yes

stuck coral
#

And you have the correct serial port selected?

formal python
#

yes

stuck coral
#

Could you pastebin your code again for me? That should be working

formal python
stuck coral
#

Im not sure, are you sure it uploaded to the arduino correctly?

formal python
#

No I didn't

#

sorry

stuck coral
#

All good

formal python
#

upload done

#

24 to 28

stuck coral
#

Alright, so that is only taking 28 microseconds max, that is not the issue, I have a feeling it is the reading and writing causing the issue. Go ahead and put the code back to the way you had it

#

Let me write you a bit of code to use instead actually, hold on

formal python
#

it is possible to add a setup for faster read / write ?

stuck coral
#

That is in the library you are using, it would require a lot of work. Hold on and we can verify what is taking a lot of time to execute

#

If there is a compiler error let me know

formal python
#

thx

stuck coral
#

Did you get that uploaded?

formal python
#

I will (I am slow)

stuck coral
#

Okay, no rush, you might have to @ me when youre done to get my attention

formal python
#

okay okay

#

thx

#

@stuck coral it's uploaded

stuck coral
#

Okay, so each loop is taking around 1488us to execute, which means your loop is updating 67 times per second, from what I know about controllers that isnt very slow

formal python
#

it is not possible to decrease this latency time?

#

what you added did not decrease the latency time?

stuck coral
#

What I did will increase it slightly but most of the time in the program is spent reading the controller which is a part of the library you are using

#

My code just adds a output so you can see where time is being spent

#

But it is not very much latency

#

Oh there is also a line of your old code missing, hold on

formal python
#

wish part ?

stuck coral
#

I missed the console.write(gcc);

obtuse spruce
#

@stuck coral & @formal python - you're off by a factor of 10. The loop is running 670x a second

stuck coral
#

Oh durrr, thanks mzero

#

Thats what I get for debugging and playing a game

formal python
#

'startWrite' was not declared in this scope

#

in you new past

obtuse spruce
#

So... skimming back through this thread.... I feel like I don't understand what problem this speeding up is trying to affect? Updating 600+ a second, if this is something about human perception - it isn't going to make a difference if it is 300x or 1200x.... that is all faster than eyes/ears/hands perceive

pine bramble
#

If it's running at 670 Hz you could toggle a GPIO pin attached to a piezo buzzer and hear it for yourself.

stuck coral
#

I agree with @obtuse spruce I dont think the arduino is introducing latency

#

If it was polling at 67 times a second and I forgot a write command sure, but not 670

#

What does that get us @pine bramble?

pine bramble
#

Just a sanity check. Reinforces what the true loop speed could be.

#

(an oscilloscope would be better)

stuck coral
#

Well lets assume the hardware does not have some absolutly critical issue... that is out of the scope of the latency issue

#

Otherwise you wouldnt be able to read the controller

obtuse spruce
#

I'd like to see the library code that supplies CGamecubeController and CGamecubeConsole

stuck coral
#

Ive got it hold on

obtuse spruce
#

anyone have the link?

stuck coral
#

However, as printing the micros values shows, the reads are taking just over a ms. Idk about writes and Id like to see that but I dont see an issue https://github.com/NicoHood/Nintendo

#

The timer is not being messed with

#

@formal python when you tried the code I just sent you, were you sure to copy and paste the entire thing?

#

Because the variable is within the scope

formal python
#

yes

stuck coral
#

Im looking at my code, and its written right, startWrite is defined and within the scope

formal python
#

yes my fault sorry

#

I uploaded

stuck coral
#

Alright, can I see serial so we know how long writes are taking?

obtuse spruce
#

only odd thing I see in that library is that it turns interrupts off during I/O with what I assume is "the old way" of turning off interrupts?

    uint8_t oldSREG = SREG;
    cli();
stuck coral
#

Oh yes, you are correct

#

So we cannot rely on micros

#

We're not using other inturrupts, could we just remove that line for now?

formal python
stuck coral
#

That looks like the old output

#

Can I see the output from the code I just sent you?

obtuse spruce
#

oh my - the library is doing bit banging Serial... coded with inline assembly.... carefully tuned to only work on a 16MHz processor (though one wonders if that is enough of a test....)

pine bramble
#

;)

obtuse spruce
#

But no matter - the code is reading and writing the correct values, right @formal python ?

#

So, @formal python - what is the issue you are seeing when using this code that makes you think it is slow?

stuck coral
#

Okay @pine bramble I get it ๐Ÿ˜† I owe u a shot. what were the chances he had a piezo anyways

obtuse spruce
#

The only thing I have to go on is - "if I only leave the minimum in the arduino, it seems faster to me" --- can you explain what feels faster, and how much?

stuck coral
#

Was a good call

formal python
#

in the last code I can't upload

stuck coral
#

My bad swap convertStart in that line for startConvert

formal python
#

@obtuse spruce yes , I feel latency

stuck coral
#

Well from what you told me, the code you added is not adding much latency, its the reads and writes that are taking time

pine bramble
#

@stuck coral Was just trying to contribute in a sciency way. ;)

formal python
stuck coral
#

@obtuse spruce what would you think about disabling the IRQ just for now to get some basic timing info even if it doesnt read right?

#

And off I forgot the println, but writes are supposively taking the longest

formal python
#

yes it is really at the level of the use that I feel the latency, the general use of the controller

stuck coral
#

What is this outputting to?

formal python
#

you talk to me ? about the screen I sharing ?

stuck coral
#

What is the arduino outputting to? I get the controller is an input

formal python
#

to fixe controller

stuck coral
#

So this is going into a game cube?

formal python
#

yes

#

wii/gamecube

pine bramble
#

bad protocol

formal python
#

i keep the code like you put on pastebin in my arduino?

pine bramble
#

The latency comes from the contents of the program, not its execution. /guess

stuck coral
#

Well its coming from the library for sure, the reads and writes

#

As mzero points out, IRQs are being disabled, and as you point out, bad protocol

pine bramble
#

The upstream author may not have worked out all the problems to bring this out of 'demo' and into 'hot rodded' level of performance.

obtuse spruce
#

@formal python - I suggest you do two things:

  1. Back out the timing code above - as it will induce latency (printing to Serial takes time) - and put in code that only prints out total loops per second every few seconds. I have code for you if you want.
  2. Change the code for nocode so that you can toggle the code off and then back on. It is important to see the effect of the latency with and without the code immediately, not with a stop and upload cycle.
pine bramble
#

Could be a reverse-engineering guessjob. ;)

stuck coral
#

Agreed @formal python should swap back, I was just using serial for some figures.

obtuse spruce
#

I don't think the library is the issue - that looks reasonable from my quick glance... and certainly isn't going to cause latency or not based on the computation in convertInputs

stuck coral
#

Well its not in anything in the main sketch

obtuse spruce
#

Use this for loop():

void loop(){
  controller.read(); 
  gcc = controller.getReport();

  if (!off) {
    ax = gcc.xAxis -128; ay = gcc.yAxis -128; //offsets from nuetral position of analog stick
    cx = gcc.cxAxis-128; cy = gcc.cyAxis-128; //offsets from nuetral position of c stick
    axm = abs(ax); aym = abs(ay);             //magnitude of analog stick offsets
    cxm = abs(cx); cym = abs(cy);             //magnitude of c stick offsets
    
    convertinputs();                 //implements all the fixes (remove this line to unmod the controller)
  }

  console.write(gcc);

  static int loopCount = 0;
  const unsigned long reportPeriod = 5000;
  static unsigned long reportTime = millis() + reportPeriod;

  loopCount += 1;
  if (millis() > reportTime) {
    Serial.print("in ");
    Serial.print(reportPeriod);
    Serial.print('ms, rean ');
    Serial.print(loopCount);
    Serial.println(" loops.");

    loopCount = 0;
    reportTime = millis() + reportPeriod;
  }
}
#

That will print out the number of loops exectued in each 5 second period.

#

D'oh - I fixed it a little bit more - we want it doing nothing but reading and writing when "off"

#

Now - the code for toggling it on or off needs to be made to toggle... hold on....

formal python
#

I waiting thx

obtuse spruce
#

I think this will work:

void nocode() {
  static bool heldDown = false;
  static bool waiting = false;
  static unsigned long toggleTime = 0;
  const unsigned long toggleHoldTime = 2000;

  if(gcc.dleft) {
    if (!heldDown) {
      toggleTime = millis() + toggleHoldTime;
      helddown = true;
      waiting = true;
      return;
    }
    if (waiting && millis() > toggleTime) {
      off = ! off;
      Serial.print("input conversion is now ");
      Serial.println(off ? "off" : "on");
      waiting = false;
    }    
  }
  else {
    heldDown = false;
    waiting = false;
  }
}
#

That will let you toggle the conversion code on or off by holding d-left down for 2 seconds

#

Oh - foo!

#

that code is called only IN convertInputs()

#

so - take this line out of there:

#
  nocode();        //function to disable all code if dpad left is held for 10 seconds
#

and move that line to just after console.write(gcc); in loop()

#

'k?

formal python
#

so I replace the :
void nocode(){
if(gcc.dleft){
if(n == 0) n = millis();
off = off||(millis()-n>2000);
}else n = 0;
}

#

with the new ?

obtuse spruce
#

yup

formal python
obtuse spruce
#

yes and yes

formal python
#

"helddown" was not declared in this scope

obtuse spruce
#

capital D my friend

#

... i make typos

formal python
#

I don't understand, I have to correct something ?

obtuse spruce
#

look at the line in error... look at the variable that it says wasn't declared. Look up a few lines, you'll see it was decalred .... but spelt with a capital D in the middle: heldDown

#

then fix the line that is red.

formal python
#

oh

#

yeah true

#

so i upload

obtuse spruce
#

okay

#

SO

#

NOW

#

you should see, every 5 seconds it printing out a loop count

#

AND... if you hold d-left down for 2 seconds, you'll see it toggle off / on the extra code you suspect is causing lag

#

while it is off ... you'll see the loop count ... and can compare that to the loop count when on

#

this gives you a measurement - how much difference is there?

#

You can also use the system - play some game - and compare the feel with it toggled on -- and toggled off ---- even better - get a friend to toggle it on or off randomly .... then play back and forth and see if you can guess which what it is!

#

BUT - for all of us here.. what numbers are you seeing?

formal python
#

numbers with the monitor ? like that :

#

?

obtuse spruce
#

yeah - are they scrolling by?

#

We don't need a picture - just tell us the number of loops in 5000ms

#

about one line per 5 seconds is what you should be seeing

topaz compass
#

Reposting my previous plea for assistance...Hey folks. I just got a new Feather Huzzah and I'm trying to upload a sketch, but the upload always fails with this rather unhelpful error: Connecting....
A fatal error occurred: Timed out waiting for packet header

stuck coral
#

@topaz compass I had that issue for a while using a front panel desktop USB that wasnt great, I would check the cable and try another USB port, if that does not work if the feather is in a socket remove it.

topaz compass
#

Thanks. Will attempt that now...

formal python
#

@obtuse spruce for that I have to add Serial.begin(115200); right ?

obtuse spruce
#

yup

#

assumed you had that...

#

and that is in setup()

stuck coral
#

I told him to swap my code back, it wasnt there to start

topaz compass
#

Same result. Additional information: after the failed upload, the on-board LED goes solid bright red and stays there.

stuck coral
#

Do you have a bunch of stuff connected to it?

topaz compass
#

Just one thing. A STEMMA temperature sensor. Think removing it could help?

stuck coral
#

Try just the HUZZAH by itself

topaz compass
#

Ok. Doing that

pine bramble
#

Desk of LadyAda was (still is?) on; lead piece was a nice bit about reverse engineering using the USART.
plate o' shrimp

topaz compass
#

Still no luck

stuck coral
#

Hm, that message means the GPIO0 pin or another boot pin isnt in its correct state, or there is a bad USB connection

formal python
#

with the new voidloop when I try to add :
unsigned long s = micros();
convertinputs();
Serial.println(micros-s);

I got no matching function for call to 'println(long unsigned int (*)())'

stuck coral
#

Swap that with Serial.println(micros()-s); @formal python

formal python
#

oh yes

obtuse spruce
#

BUT - if you add that code you will totally throw the timing of loops per interval off : Serial.print takes significant time

#

It is fine for measuring just one thing --- but you can't use it for finding out how fast the code as a whole is --- we are trying to establish that loop() will execute in the 100s a second - and pretty much the same wether conversion is toggled on or off

formal python
#

BUT - for all of us here.. what numbers are you seeing?
@obtuse spruce

#

so you don't talk about Serial.println(micros()-s); ?

obtuse spruce
#

no

topaz compass
#

Interesting? info from "Get Board Info" : BN: Unknown board
VID: 10C4
PID: EA60
SN: Upload any sketch to obtain it

stuck coral
#

Doesnt really tell you anything

obtuse spruce
#

In the code I gave you - every 5 seconds (if I coded it right ๐Ÿ˜„ ) - it will print out a line like:

in 5000ms, ran 3134 loops
formal python
#

in the serial monitor right ?

#

where I can see "in 5000ms, ran 3134 loops" ? in the serial monitor nothing happen

obtuse spruce
#

should be there - once every 5s

#

do you see the code that would write this line - at the end of your loop() code?

formal python
#

loopCount += 1;
if (millis() > reportTime) {
Serial.print("in ");
Serial.print(reportPeriod);
Serial.print('ms, rean ');
Serial.print(loopCount);
Serial.println(" loops.");

loopCount = 0;
reportTime = millis() + reportPeriod;

}
}

obtuse spruce
#

that's the code - should be running every 5 seconds.... You did copy-n-paste my code, right?

pine bramble
#

;)

formal python
#

I do

#

Use this for loop():

void loop(){
  controller.read(); 
  gcc = controller.getReport();

  if (!off) {
    ax = gcc.xAxis -128; ay = gcc.yAxis -128; //offsets from nuetral position of analog stick
    cx = gcc.cxAxis-128; cy = gcc.cyAxis-128; //offsets from nuetral position of c stick
    axm = abs(ax); aym = abs(ay);             //magnitude of analog stick offsets
    cxm = abs(cx); cym = abs(cy);             //magnitude of c stick offsets
    
    convertinputs();                 //implements all the fixes (remove this line to unmod the controller)
  }

  console.write(gcc);

  static int loopCount = 0;
  const unsigned long reportPeriod = 5000;
  static unsigned long reportTime = millis() + reportPeriod;

  loopCount += 1;
  if (millis() > reportTime) {
    Serial.print("in ");
    Serial.print(reportPeriod);
    Serial.print('ms, rean ');
    Serial.print(loopCount);
    Serial.println(" loops.");

    loopCount = 0;
    reportTime = millis() + reportPeriod;
  }
}

@obtuse spruce

#

I replaced the old void loop with this void loop

obtuse spruce
#

@stuck coral & @pine bramble - wanna eyeball that for me.... I think I got the code right

#

And you do have Serial.begin(115200); in setup(), right?

formal python
#

yes

obtuse spruce
#

they are static

stuck coral
#

Yep nevermind, looks good to me

obtuse spruce
#

loves static variables

stuck coral
#

I dislike them, the C++ syntax makes it hard to read because it makes it seem that the initializer is always being set

#

Well, not hard but can trip me up

obtuse spruce
#

True, but the benefit of being close the point of usage, and name scoped out of the way of everything else is VERY VERY big.

#

@formal python - Try adding this line just after console.write(gcc)::

  Serial.println("hi");
pine bramble
#
Serial.print('ms, rean ');
```Not sure what the single quotes are doing.
formal python
#

he said hi hi hi hi

#

very fast

stuck coral
#

I agree with @pine bramble the single quotes is incorrect, but it should still be printing something in the if statement

pine bramble
#

I just don't know what a multiple char '\n' utterance is.

#

There was a discussion about it; I believe it's legal C.

stuck coral
#

I would like to hear it but I have seen it used and also believe its legal

#

Not sure why or how, maybe compiler voodoo

pine bramble
#

It made sense -- I just don't remember the punch line. ;)

stuck coral
#

Oh because a /n is a ASCII newline if I remember right 0x0a.... might be wrong on that

#

Because you can have in a text document the chars \n and it wont display a newline

obtuse spruce
#

(sorry - was on a plum torte dessert break)

#

So - okay --- @formal python -- take out the "hi" line you added, and fix this line I mis-typed:

Serial.print("ms, ran ");
#

notice that it changed from single quotes to double quotes.

#

good eye, @pine bramble

stuck coral
#

Would that cause nothing to be printed? Im amazed

formal python
#

in setup void right?

obtuse spruce
#

no - that is in loop()

formal python
#

just after the line " console.write(gcc);" right?

reef ravine
#

@stuck coral since ' is for a single char maybe it just printed the last space

pine bramble
formal python
#

@obtuse spruce nothing happen

obtuse spruce
#

if you replace the if line:

#
  if (millis() >= reportTime) {

with

  if (true) {
#

does it print then?

formal python
#

work

#

ms, ran in 5000281921 loops.

#

is there any improvement?

obtuse spruce
#

please cut-n-past the code for loop() as it now stands?

pine bramble
#

fades .. ร  bientรดt.

formal python
#

@obtuse spruce where do you see the code for loop ?

reef ravine
#

the entire void loop(){ ... } function, all the code it runs in the main loop

wooden crescent
#

ok.. i'm getting really frustrated with these adafruit libs..

#

i've been having problems for 12 hours with a pro micro, sdcard module, and SSD1306 oled module

#

I just realized what is actually happening... it's out of ram.. which i'm not sure how that isn't caught somewhere in code.. i mean shouldn't a malloc() fail somewhere, instead of allocating more ram than what is available?

#

^ but that's an arduino thing

#

however.. the adafruit SSD1306 libs return valid upon Display.begin() -- EVEN WHEN NO DISPLAY IS PRESENT...

#

and still takes up the same amount of memory, and causes everything to not work as intended..

#

I mean.. if there is nothing on the i2c bus.. shouldn't it return something other than successful?

#

sorry---done

formal python
#

Use this for loop():

void loop(){
  controller.read(); 
  gcc = controller.getReport();

  if (!off) {
    ax = gcc.xAxis -128; ay = gcc.yAxis -128; //offsets from nuetral position of analog stick
    cx = gcc.cxAxis-128; cy = gcc.cyAxis-128; //offsets from nuetral position of c stick
    axm = abs(ax); aym = abs(ay);             //magnitude of analog stick offsets
    cxm = abs(cx); cym = abs(cy);             //magnitude of c stick offsets
    
    convertinputs();                 //implements all the fixes (remove this line to unmod the controller)
  }

  console.write(gcc);

  static int loopCount = 0;
  const unsigned long reportPeriod = 5000;
  static unsigned long reportTime = millis() + reportPeriod;

  loopCount += 1;
  if (millis() > reportTime) {
    Serial.print("in ");
    Serial.print(reportPeriod);
    Serial.print('ms, rean ');
    Serial.print(loopCount);
    Serial.println(" loops.");

    loopCount = 0;
    reportTime = millis() + reportPeriod;
  }
}

@obtuse spruce

#

here

formal python
#

very quick question, it is possible to disable the internal led of the arduino with coding ?

reef ravine
#

not the power LED, no

sinful nimbus
#

Quick question, if I'm using an esp8266 and the 12,13, and 14 pins are take, what pin should I use for a tilt switch?

#

This is on a feather Huzzah

#

I was thinking 16 but it isn't working how I thought so I think i may have goofed in my pin selection

cedar mountain
#

Are you using 16 for the special deep-sleep wakeup function, or just as a regular GPIO?

nimble cobalt
#

Hey if anyone is around and has a few, I'd like understand rotary encoders a bit. I just received a set of encoders and all 5 of them set up seem to give inconsistent data when turning the dials in any direction. Beating my head on it for a couple of hours now

cedar mountain
#

Are they quadrature encoders, or few-bit position encoders?

nimble cobalt
#

I've gone through quite a few examples and this is the last one I've used:

  static int LastState;
  int Clock;
  if(LastState == (Clock = digitalRead(altitudeClockPin))) return; // No Change
  LastState = Clock;
  if(Clock == 0) return; // Clock Went Low
  //Clock went High
  if (current - lastAltitudeRotaryDial > 100)
  {
    (digitalRead(altitudeDataPin))? Serial.println("ALTITUDE_UP"): Serial.println("ALTITUDE_DOWN");
    lastAltitudeRotaryDial = current;
  }```
cedar mountain
#

Gotcha. It looks like they're calling CLK and DT the usual quadrature encoder A and B signals.

nimble cobalt
#

Yea, that is what I have read

#

this is the funkiest example I've used so far, lol. I've tried the other more basic ones as well. I just find it odd that all 5 dials are outputting to me the same (I have only switched them out from the same circuit)

cedar mountain
#

It's not obvious to me how the code works. The fact that it's updating the state from A all the time but only looking at B with a millis() delay seems to indicate that you might be missing some transitions.

nimble cobalt
#

I'll show you another example I have used, with same results

cedar mountain
#

What sort of results are you seeing?

nimble cobalt
#

basically no matter the direction i turn the dial, I am getting a mix of the Serial.println("ALTITUDE_UP"): Serial.println("ALTITUDE_DOWN");

#
  int current = millis();
  if (rotaryCurrentClock != altitudeClockLast && (current - lastAltitudeRotaryDial > 500))
  {
    if (digitalRead(altitudeDataPin) != rotaryCurrentClock)
    {
      Serial.println("ALTITUDE_DOWN");
    }
    else
    {
      Serial.println("ALTITUDE_UP");
    }
    lastAltitudeRotaryDial = current;
  }

  altitudeClockLast = rotaryCurrentClock;```
#

never mind the 500 , its just the latest tinker to it

#

even at that amount of debounce, i still get a mix of outputs

#

that is just on turning it clockwise

candid topaz
#

rotary encoder and debouncing?

nimble cobalt
#

its the same without it

candid topaz
cedar mountain
#

Gotcha. I'm still a bit confused by the algorithm, so I'd just advise doing more of a classic A/B state machine approach.

nimble cobalt
#

I have tried that code as well ๐Ÿ˜ฆ

#

the simplified example one

#

and the interrupt example

sinful nimbus
#

. @cedar mountain regular gpio!

nimble cobalt
#

I've just now tried this from the simplified example again:

  
  if ((altitudeClockLast == LOW) && (rotaryCurrentClock == HIGH)) {
    if (digitalRead(altitudeDataPin) == LOW) {
      Serial.println("ALTITUDE_UP");
    } else {
      Serial.println("ALTITUDE_DOWN");
    }
  }
  altitudeClockLast = rotaryCurrentClock;```
#

no matter which direction, it is printing ALTITUDE_DOWN at least 90% of the time

#

no debounce

cedar mountain
#

@sinful nimbus What problem are you seeing?

sinful nimbus
#

I apologize if I randomly disappear, it's almost 3 a.m. here my wife will be mad if I stay up at me later

#

But basically the Tilt switch will activate but then it won't go back to its previous state

candid topaz
#

digitalWrite(inPin, HIGH); // turn on the built in pull-up resistor

#

i am not sure about this

sinful nimbus
#

And I'm sure there must be something that I'm doing wrong on the software side. I tested the switch with a multimeter and it seems to be okay

nimble cobalt
#

time =r millis(); is that a typo, or is that in your code

sinful nimbus
#

Typo

nimble cobalt
#

k ๐Ÿ˜„

candid topaz
#

what if you try pinMode(inPin, INPUT_PULLUP)

sinful nimbus
#

I've actually tried that. That's actually the original code that I was testing it on

#

og code

#

When that didn't work I decided to just go to a very simple example, to see if there was something weird

#

I also tested the switch with a multimeter and it seems to work fine

magic field
#

attachInterupt( what types are these here? )

sinful nimbus
#

?

nimble cobalt
#

I find that if I turn through the detents very slowly, I get my desired output. But any sort of rotation faster, even if I still just go detent to detent, I get my usual mix of outputs.

nimble cobalt
#

I was finally able to find some code that solves it

#
  static int8_t rot_enc_table[] = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0};

  prevNextCode <<= 2;
  if (digitalRead(altitudeClockPin))
    prevNextCode |= 0x02;
  if (digitalRead(altitudeDataPin))
    prevNextCode |= 0x01;
  prevNextCode &= 0x0f;

  // If valid then store as 16 bit data.
  if (rot_enc_table[prevNextCode])
  {
    store <<= 4;
    store |= prevNextCode;
    if ((store & 0xff) == 0x2b)
    {
      val = -1;
    }
    if ((store & 0xff) == 0x17)
    {
      val = 1;
    }
  }
  else {
    val = 0;
  }

  if (val)
  {
    if (prevNextCode == 0x0b)
    {
      Serial.println(commandUp);
    }

    if (prevNextCode == 0x07)
    {
      Serial.println(commandDown);
    }
  }```
candid topaz
#

O_o

pine bramble
#

That seems to be the essence of quadrature encoding.

#

I have unpublished working code for an Arduino SAMD21 project that does rotary encoder.

It's definitely sensitive to the speed of rotation - no doubt at all.

#

If you want to slew rapidly, it can do that, but it's calibrated within a fairly narrow range of rates-of-turn. (or RPM).

#

๐Ÿ”น

#

I needed nimble accuracy at slow turning rates (to select menu items displayed on an LCD, by turning the rotary encoder and using its inbuilt switch).

Pressing the switch (end of encoder shaft) makes the selection known to the microcontroller.

#

Faster turning rates dropped clicks (encoder detent crossings).

#

// mirror symmetry ... or palindrome

const int8_t KNOBDIR[] = {
   0, -1,  1,  0, 1,  0,  0, -1,
  -1,  0,  0,  1, 0,  1, -1,  0
};
elder hare
#

Question, i removed these to make the 8x8 flush with the board and the rest of the matrix! Question is the chip (GC7219C 1906+) will it get to hot? Now that the matrix is that close to it?

north stream
#

I doubt the matrix is dissipating enough heat to be an issue.

elder hare
#

never buying from banggood again -.- bad PCB -.- the solder pads went right off

main olive
stuck coral
#

That is not an issue with the code

main olive
#

oh

pine bramble
#

@main olive You can capture the error using your mouse.

stuck coral
#

I would try another cable or USB port first, which OS are you on?

main olive
#

windows.

pine bramble
#

Swipe the orange text and copy it (control c) to the clipboard, then paste it somewhere.
Could be very long text so maybe pastebin.

main olive
#

Error compiling for board Arduino Uno.

#

or the whole thing?

stuck coral
#

Ah, I thought it was the error I saw earlier, so that is a code issue

pine bramble
#

The whole thing.

#

Don't paste it here, that'd be atrocious. ;) lol

main olive
pine bramble
#

There should be dozens or hundreds of lines of text.

stuck coral
#

There is no main loop

pine bramble
#

Arduino IDE, lower half of the window.

stuck coral
#

Arduino requires a loop(){} to be defined

pine bramble
#

If there's no loop then everything I said does not yet apply.

main olive
#

ooh

#

i fixed it

pine bramble
#

You can have an empty loop, when all your code is in setup().

#

When it gets to loop(); it just loops infinitely.

deep salmon
#

I have an external 12v battery with 2.4amps. Is it bad to have 2amps being fed into my Arduino uno? It gets really hot and auto shuts off after 5 seconds of running. I have a 5v stepper and a 3.3v laser running (200ma). It works find if the laser isnt hooked up.

pine bramble
#

@deep salmon 12v sounds high for the Uno. What's the spec for it say?

pine bramble
#

200 mA may be a bit much at 3.3 V. I didn't know the Uno had a 3.3V output.

deep salmon
#

it's a knock-off board tho

#

I'm using the 5v to power both the stepper and the laser. I use a buck converter to drop the voltage down to 3.3 for the laser

pine bramble
#

Try running everything as a stress test, except disconnect the laser. You probably have found the voltage regulator IC which is usually the part that gets hot when there's too much current drawn.

#

If anything is too hot to touch shut it all down immediately. ;)

#

And if it got that hot, don't retry the same thing immediately; needs time to cool down.

deep salmon
#

yep, when I disconnect the laser it runs fine for a long time. With the laser it gets super hot, right next to the barrel connector port after 5 seconds

pine bramble
#

Right, so don't do that anymore.

#

You're not going to get a different answer the seventh time you try it. ;)

#

Be extra careful with the laser, it may be a dead short.

#

(zero ohms)

deep salmon
#

here's the laser in question

pine bramble
#

(which is also the site of Sam's Laser FAQ btw)

north stream
pine bramble
#

;) Yeah I read it in depth about 10 years ago.

north stream
pine bramble
#

And you can still see out of both eyes, huh. ;)

north stream
#

I play with lasers, fireworks, and high voltage and I'm still alive and have both eyes and all my fingers and toes. My hearing, however, isn't so great.

wooden crescent
#

anyone ever try to make the adafruit ssd1306 lib work on an stm?..

obtuse spruce
#

Does the STM core have SPI.h or Wire.h?

#

I'd assume so....

obtuse spruce
#

Then I'd imagine that the Adafruit_ssd1306 should work just fine, @wooden crescent

pine bramble
#

If you can build and run an Arduino sketch on the STM32F405 Express, that's the hard part of the learning curve. That first working sketch you wrote (or just uploaded).

#

After that the differences between STM32F405 Express and other Arduino target boards aren't as important.

#

That's the entire point of the Arduino ecosystem. ;)

mellow flax
#

The Amazon Basics Micro B cable should work for serial connection right?

#

for some reason none of the cables I already own are working

stuck coral
#

You are trying to establish a serial connection over USB to a board with a USB micro connector using arduino?

mellow flax
#

yes

stuck coral
#

What OS are you using?

mellow flax
#

windows

pine bramble
#

They're going to be selling those to anyone who wants to side-load onto a cell phone, a Kindle and whatnot.

mellow flax
#

it's not showing under ports at all

#

like my uno or mega

pine bramble
#

You should have several USB cables to try.

mellow flax
#

yea I have more coming in the mail tomorrow

stuck coral
#

Is the board getting powered @mellow flax?

mellow flax
#

yes

#

I should be clear that I haven't tried the amazon basic cable yet

#

its being delivered tomorrow

stuck coral
#

Ah, lets try that then report back

mellow flax
#

but that is a cable that should be capable correct?

#

not "charge only"

pine bramble
#

I think people want data transfer.

#

otoh, amazon.

stuck coral
#

Yeah, dont get a charge only cable

pine bramble
#

Whoever came up with 'charge only cable' needs to go to the Special Place.

#

If you happen upon a charge-only cable, you can cut it in half with scissors. Failing that, tie a knot in it.

stuck coral
#

I agree

pine bramble
#

I like the USB-A to 2.1 mm barrel plug because .. hey .. barrel plug.

#

No confusion there. ;)

narrow jackal
#

How can I build a circuit for multiple stepper motors?

north stream
#

You can either use H-bridge chips and control them directly, or use stepper motor control chips and send them commands.

narrow jackal
#

I'm using DRV8825s
The way it rn is that the Arduino is plugged into a Pi and the Pi picks which motor to move and how many steps through serial commands

#

The first motor (the druver on the far left) is very smooth and works perfectly
The second motor (the driver in the middle) moves at a snail's pace and moves in small step increments

#

Is it because the capacitor for the first driver is stealing away the current from the second driver and it diminishes down the rail?

#

How can I make sure they get equal power?

north stream
#

Hmm, those are fairly basic controllers, they have enable, direction, and step inputs. I would guess a power supply issue or a problem with the Arduino code.

narrow jackal
#

hmm

north stream
#

I'd probably try swapping the signals from the Arduino to the first two drivers and see if the problem moves. If so, it's more likely an Arduino problem. If it doesn't, it's more likely a wiring/power problem.

narrow jackal
#

Swapping the signals?

#

Okay

#

You mean the pins on the arduino yes

north stream
#

Yes, take the signals connected the left driver and swap them with the signals connected to the middle driver.

narrow jackal
#

It might be an Arduino problem

#

Whatever is "motor A" (pins 2 and 3) in the code works well and whatever is "motor B" (pins 4 and 5) in the code stalls

north stream
#

That's a useful clue.

narrow jackal
#

I'm using AccelStepper

north stream
#

That's normally a pretty solid library. I wonder if it's getting interrupts that keep it from finishing, or there's something odd about those pins, or what.

narrow jackal
#

Maybe my code is just terrible xD

#
#include <AccelStepper.h>

#define dirPin 2
#define stepPin 3
#define dirPin2 4
#define stepPin2 5
#define motorInterfaceType 1

int SPEED=200;

AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);
AccelStepper stepper2 = AccelStepper(motorInterfaceType, stepPin2, dirPin2);

//Steps the motor
// Stepper object, number of steps, previous position of stepper motor
void stepMotor(AccelStepper myMotor, String motorSteps, long int previousPosition){
 while (myMotor.currentPosition() != previousPosition+motorSteps.toInt()){
        if (motorSteps.toInt()<0){
          myMotor.setSpeed(-SPEED);
          } else {
          myMotor.setSpeed(SPEED);
          }
          
        myMotor.runSpeed();
      }
}

void setup()
{
  //Open serial communication
  Serial.begin(9600);
  // Setting the positions and max speeds of the two steppers
  stepper.setCurrentPosition(0);
  stepper.setMaxSpeed(1000);
  stepper2.setCurrentPosition(0);
  stepper.setMaxSpeed(1000);
}

void loop() { 
  long int prevPos=stepper.currentPosition();
  long int prevPos2=stepper2.currentPosition();
  String motor="";
  
  //Stalls the program until new serial data comes in
  while (Serial.available()<=0){}
  
  if (Serial.available() > 0) {
    motor = Serial.readStringUntil('\n');
    Serial.println(motor);
    if (motor=="A" || motor=="B") {
      Serial.println("Motor received.");
      } 
  }
  //Motor end

  //Stalls the program until new serial data comes in
  while (Serial.available()<=0){}
  
  if (Serial.available() > 0) {
    String steps = Serial.readStringUntil('\n');
    Serial.println(steps);
    if(motor=="A"){
      stepMotor(stepper, steps, prevPos);
      } else if (motor=="B"){
      stepMotor(stepper2, steps, prevPos2);
      }
  }
  //Steps end

  Serial.println("Finished!");
}```
#

How it works is that the Arduino waits until the Pi sends the string "A" or "B"
Then it sends confirmation and the Pi sends a number of steps
Then the Arduino moves the given motor that many steps before saying it's done and letting the Pi give it more instructions

#

I can't see how it favors motor A more than motor B though

reef ravine
#

my bad, nvm

#

the pinModes are not being set in setup(), it works somewhat?

oblique bramble
#

is there a way for a led to turn on when a button is pressed and stay on until the button is pressed again without Arduino and just simply logic components

reef ravine
#

google up "flip flop circuit"

oblique bramble
#

okay thank you very much!

north stream
#

You can build it out of logic gates, or just two transistors (or vacuum tubes) and a handful of passive components.

oblique bramble
#

does the circuit change if i need like 50-60 buttons and leds?

north stream
#

That depends. Are they all independent (that is, each button has its own LED that it controls) or do they interact somehow?

oblique bramble
#

yes they are all independent

#

i think it should be a simple circuit but i have no idea

north stream
#

Yes, it's a fairly simple circuit, but you'd need one for each switch/LED.

tacit plaza
#

What syntax would I use to change " delay(750) ; " to a random value between 25-750 ? (or link to appropriate function?)

cedar mountain
tacit plaza
#

Thanks. I couldn't find my bookmark to the reference pages.

atomic goblet
#

Hey, quick question: rtc.adjust(DateTime(F(DATE), F(TIME))); just sets my system time as the rtc's time?

lone ferry
#

@atomic goblet It sets the time that you compiled the program as the RTC's time.

mellow flax
#

any idea why I might be getting these rythmic spikes in my temperature data

#

using the DS18B20 sensor until my thermistor arrives
going to plot it again in 7 hours or so to see if it continues

#

feels WAY too uniform to be real

lone ferry
#

What is the horizontal axis? I mean, what unit of time? @mellow flax

mellow flax
#

hours

#

each point is a minute

lone ferry
#

So that peak happens every 20 minutes or so?

mellow flax
#

around 30

#

its within the documented error of +- 0.5

#

but the rhythmicity is rlly weird

lone ferry
#

Is there anything else that turns on/off every 30 minutes where you are?

mellow flax
#

not that I'm aware of

#

going to bed

#

I'll try powering it up with my UPS when I wake up

north stream
#

Looks like air conditioner/heater cycling to me.

rugged smelt
#

hi i have problem with my esp8266 board im trying to do code with display and i define pins #define CLK D2 #define DIO D3 but every time it said D2 was not declared in the scope

gilded swift
#

hmm

#

I don't think D2 is correct

rugged smelt
#

with 2 nothing change

#

rly

#

just dont do anything

gilded fulcrum
#

hi i have problem with my esp8266 board im trying to do code with display and i define pins #define CLK D2 #define DIO D3 but every time it said D2 was not declared in the scope
@rugged smelt
https://github.com/ThingPulse/esp8266-oled-ssd1306/issues/156
this might help you

#

different 8266 boards have different gpio notation

rugged smelt
#

thanks

trim vigil
#

Hello, I have been struggling to get my Adafruit Huzzah feather to connect to my laptop (OSX 10.15.6). Are these perhaps deprecated? I'm assuming my troubles are with the SILabs USB driver. The port does not appear in the arduino IDE and the extensions shows "No" under the Loaded column when I run a system report. There is nothing to enable/authorize in the security area and I found another post related to forcing it to be allowed in recovery mode. Currently out of ideas and thought I would reach out here.

north stream
#

Apparently Apple started shipping their own driver for the CP2102, but it binds to all devices in the CP21xx family but doesn't support any of the other ones.

trim vigil
#

Apparently Apple started shipping their own driver for the CP2102, but it binds to all devices in the CP21xx family but doesn't support any of the other ones.
@north stream Are there any work arounds? Maybe I'll use the PC in this case.

north stream
trim vigil
#

Apple appears to have removed the problematic driver as of macOS 10.15.3.

#

Well it looks to be working now. Thanks for the information!

north stream
#

Thanks for the update!

magic needle
#

Well, another issue while learning here, I've re-written it and I cant figure out why I get this on the serial monitor, I've only given the one input.

#

float radius;
float area;
float pi = 3.14;
String msg = "What is the radius of your circle?";
String msg2 = "Your circle has an area of ";

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
Serial.println(msg);
while(Serial.available()==0){
}
radius = Serial.parseFloat();
area = piradiusradius;
Serial.println(area);
}

#

serial monitor:
What is the radius of your circle?
6358.50
What is the radius of your circle?
0.00
What is the radius of your circle?

north stream
#

I'm guessing here, but I think parseFloat() grabs characters as long as they're numeric, but when the loop comes around again, the carriage return is still there?

magic needle
#

It also did it with parseInt()

#

It's throwing me off because I don't want it to mess up anything in the future. At first I thought it was the Raspberry Pi I'm using, but I get the same results on my Windows PC.

cedar mountain
#

You can do parseFloat(SKIP_WHITESPACE) to have it skip over carriage returns, if that's the issue.

magic needle
#

Unfortunately that didn't change it.

cedar mountain
#

Is there about a 1-second delay before it continues? If so it's probably hitting a timeout, so you could increase that with Serial.setTimeout.

magic needle
#

Where would that go then? I'm unfamiliar with that command.

#

And about 1-2 sec, yes.

reef ravine
#

setting the serial monitor to "No line ending" works, is it set to "Both NL & CR" now?

#

this is the output with inputs of 50 and 40:

7850.00
What is the radius of your circle?
5024.00
What is the radius of your circle?
magic needle
#

Holy crap, that was it! Thank you! It was bothering me all day. And of course the tutorial was following never brought that up.

Would it be a good idea to keep that setting all the time?

reef ravine
#

it depends on the application, many things look for input to terminate with CR (0x0D), LF (0x0A) or both

#

in this case the (SKIP_WHITESPACE) caught the carriage return but not the new line

cedar mountain
#

Seriously? Lame... Good debugging, though. ๐Ÿ’ฏ

reef ravine
#

now i just wonder why it's "NL & CR", nobody uses LF + CR, it's always CR + LF...

wintry heart
#

hey could anyone help me with some code im fairly new to arduino and im trying to get an oled working

#

any help much appreciated ๐Ÿ™‚

gilded swift
#

If you post your code to paste bin and share the link, it will help

wintry heart
#

so im just trying to find my oled's i2c address and i found some code that should do it. I installed all the libraries that needed to be used but i might have missed one because when i verify the code i get an error message

gilded swift
#

Add quotes around wire.h

#

Or no sorry

#

#include <Wire.h>

#

Try without the space and capital W

wintry heart
#

ok

#

ill try thanks

gilded swift
#

The overarching concept is the same

wintry heart
#

thanks! it seems to work but i might need more help in a couple minutes if you can

gilded swift
#

Sure!

wintry heart
#

@gilded swift never mind i got it working thanks for your help

gilded swift
#

Youโ€™re welcome ๐Ÿค“

wooden crescent
#

@obtuse spruce yes the stm32's have wire.h and spi.h

#

i got i2c working.. but absolutely no SPI what so ever besides the CS line

#

I didn't have time to figure out what it was doing/where it was actually going to..

#

but it wasn't going to any of the stm designated spi pins...

#

i finally broke down, and tried an UNO... (not enough memory again)

#

and then moved on to a 2560... which worked as expected first try...

#

too bad i deleted 90% of my code troubleshooting all of these other MCU's that didn't work..

#

oh... the ESP wasn't working either.. again.. SPI never worked on any of the designated pins... only CS was working...

obtuse spruce
#

(So glad I just stumbled into starting out with a Feather M0 and Feather M4... everything on them has "just worked" ... and plenty of everything to play with.)

north stream
#

I've had similar experience, the ESP and nRF chips seem to be a little rough around the edges, but the M0 and M4 (and Teensy) are solid.

deep tapir
#

My servos are jittering when I connect them to the arduino

#

Im also runnin 2 roboclaws and 2 distance sensors with the arduino

#

could it be because of not enough current

frank skiff
#

Does anyone know if arduino IoT cloud is compatible with wpa2 enterprise networks?

ivory gorge
#

speaking of arduino IoT, I have one of these https://store.arduino.cc/usa/mkr-wifi-1010 from an iot convention and I'm wondering if I can use this with some neopixels to make some accent lighting at my desk, but the adafruit neopixel guide says the neopixel library is made for "most anything with an Atmel AVR 8-bit processor from 8 to 16 MHz", and the arduino mkr has a cortex m0, so I'm unsure if it's compatible?

ivory gorge
#

ok so I got the ide set up and when I try to use it I just keep getting this error every time I try to load code onto the board

#

(this happens regardless of what code I try to upload, btw)

#

this also happens when I use a different USB port on my computer.

#

ah, nvm, it just appears windows is being windows, I switched back over to mac and it's working fine now. hooray, rainbows are filling my room

vivid rock
atomic goblet
#

@atomic goblet It sets the time that you compiled the program as the RTC's time.
@lone ferry it doesn't work. I think I killed it while soldering it on :( it either shows the time i disconnected it before soldering or year 2165.. ๐Ÿ˜• if I try to enter a specific time there's no change in the output

ivory gorge
#

@vivid rock thanks for the tip! I modified one of the default (non-dma) samples to strip out all the things I didn't need and it worked perfectly, thank you for the help though!

lone ferry
#

@atomic goblet What if you remove the battery? That will reset the RTC.

grave island
#

hey, if I want to control the on off an dc motor (water pump) with a remote control what can I do? I have the code for the ir remote, but I don't know how to control the motor, that it has just 2 cables....

atomic goblet
#

@atomic goblet What if you remove the battery? That will reset the RTC.
@lone ferry I don't think I can remove it. It is not soldered but glued I think. I'm kind of hesitant to just ripe it out

lone ferry
#

@atomic goblet What is your full Arduino code for changing the time?

atomic goblet
#

@atomic goblet What is your full Arduino code for changing the time?
@lone ferry I used the sample included in the ds3231 library. Just picked the code from above out of the condition brackets and ran it

lone ferry
#

Could you copy-paste the entire program anyway? Sometimes what people describe isn't actually what the code does. ๐Ÿ˜‰

north stream
#

@deep tapir While it could be a current problem, I'm guessing it's more likely a timing issue or electrical noise.

elder hare
#

so i know that PyQt is just a python wrapper for Qt C++, is it better to port my PyQt Gui to Qt C++? and is it easier to create a .exe file for that?

pine bramble
#

How can i check if my Atmega 32A microcontroller is bootloaded or not? Also can i Bootload my microcontroller with FTDI ?

gilded swift
#

as for figuring out if it is bootloaded, try to upload a sketch to it

pine bramble
#

Using FTDI?

gilded swift
#

yeah

#

ft232r is a pretty common USB to serial IC for programming sketches

#

you would need to connect it to the tx/rx pins (crossed FT RX to 32A TX, FT TX to 32A RX)

pine bramble
#

hmm alright Thanks i'll try it.But im not sure if i can upload the code with atmel studio cause it's require it's own AVR programmer like atmel ice

gilded swift
#

you can download the adruino ide

pine bramble
#

i already have installed. ok i try uploading blink sketch to it using arduino ide