#help-with-arduino
1 messages · Page 70 of 1
12 bit serial data output over 2 wire i2c
Do you think it’s feasible for the attiny25 to handle?
Probably. RAM might be more of a limit than flash.
Yeah, that was also something I was thinking about.
I suppose the only way to know for sure is to build it and see
That's what I'd do: probably faster than trying to figure it out.
is it possible to make webcam using https://www.googleadservices.com/pagead/aclk?sa=L&ai=DChcSEwiK5cLe6ZTrAhVUrpYKHbQzDAMYABAGGgJ0bA&ohost=www.google.com&cid=CAESQeD2Keu_UZB8rcsm2NxyPgnDLTOi_SJ0NJzs7MRRG-hw_zpTR37pclDCHcusz2y-zNBDIYkX8_larh0Az8c_WnvV&sig=AOD64_3uvVc4sPAsP4PZ8sIiQg9I81RqHA&ctype=5&q=&ved=2ahUKEwj01LPe6ZTrAhVszjgGHcc4AK8Q9aACegQIDRA9&adurl=
Buy OV7670 Camera Module for Arduino online at lowest price in India with best quality only on ElectronicsComp.com. Purchase now with Free Shipping and COD option.
anyone tell please
Probably
Why?
The answer is sort of. If you need a webcam buy a webcam. The bitrate will be very poor, and the sensor will not be working in the provided working specifications unless you use a SAMD51 based board but will technically take photos and can send that over USB
And the SCCB bus is a pain, some people get it to work over normal i2c but Ive had no joy
Can I use a MOSFET to switch on and off a power supply?
Would I need relays?
If the max on the MOSFET is 50A and 200V and my power source is 12V 1.5A will it still be compatible
is it safe to connect my arduino directly to a power bank? I heard some power banks turn off after some time from low consumption rates but is it possible that a power banks burns the arduino?
anything is possible if it supplies too much voltage/current
if it's within 6-12V everything should be good
fry
But if it's like 6V it might output less voltage than usual
its through usb so the voltage should be 5V if im correct
but I still don't wanna test it
dont wanna kill my arduino mega
as long as it is USB, it MUST be 5 V - at most 5.25 - and it is safe to connect to an arduino, no matter what capacity is your powerbank
Completely new to arduino and just bought Elegoo's uno complete starter kit. I've watched a couple videos from BV3d: Bryan Vines to help me get started with setting up a development environment and getting familiar with each part of the kit. I plan on continuing with his series of videos on arduino, but does anyone have other channels or websites that have a complete class.
You can use the Mega's on-board regulator to operate safely from higher voltages. Most USB power banks are okay, but cheap ones can zap things
There's gonna be a voltage regulator it should be a little more
New to Arduino Hello, I have a ESP-01s and am trying to figure it out. I uploaded the Blink example and was able to run it perfectly, but when I do the simple BareMinimum AT test, I am unable to get a response. Any thoughts?
some USB battery packs turn off if the current is too low
That too: there are packs designed not to (they'll run down faster, however)
@stone dirge Does it give errors in the serial monitor ?
@quartz furnace No. When I AT test it, nothing is returned
Oh btw, I have the monitor set at "Both NW & CR" and 115200 Baud
Can FauxmoESP only be used for simple voice commands?
as in "turn device on" or "turn device off"
If I were to make an Alexa skill, would I still be able to use FauxmoESP?
@stone dirge hmmm how about a simple Serial Print Sketch .. does it print to the Serial Monitor ?
So I tried the "Hello World" example from a booklet that came with a learning kit I bought. It didn't work, but I think I didn't write the code correctly (I likely didn't account for different conditions that the esp8266-01 has).
the booklet is for uno/mega 2560
Hmmm since the code is short for a “Hello World” can you post it here ?
This is the original, unaltered code:
int val;//define variable val
int ledpin=13;// define digital interface 13
void setup()
{
Serial.begin(9600);// set the baud rate at 9600 to match the software set up. When connected to a specific device, (e.g. bluetooth), the baud rate needs to be the same with it.
pinMode(ledpin,OUTPUT);// initialize digital pin 13 as output. When using I/O ports on an Arduino, this kind of set up is always needed.
}
void loop()
{
val=Serial.read();// read the instruction or character from PC to Arduino, and assign them to Val.
if(val=='R')// determine if the instruction or character received is “R”.
{ // if it’s “R”,
digitalWrite(ledpin,HIGH);// set the LED on digital pin 13 on.
delay(500);
digitalWrite(ledpin,LOW);// set the LED on digital pin 13 off.
delay(500);
Serial.println("Hello World!");// display“Hello World!”string.
}
}
mind you I am a complete amateur with this. my only coding knowledge is from a c++ class I took 10+ years ago, so I don't remember anything
obviously when I did the code for the esp-01s I adjusted the baud rate and ledpin
How about this sketch to simply troubleshooting
void setup() {
Serial.begin(9600);
Serial.println("Hello World!");
}
void loop() {
}
should i keep the baud rate at 9600 or 115200?
I’d go with 115200 and edit the 9600 in the pasted code
ok
so just to be clear, I upload to the esp-01s with the usb adapter set to uart and then reset and flash boot it correct?
Okay I just ran the code and nothing is happening
led is on, but no response on monitor
Any errors on the Arduino IDE?
no errors that i notice
is this something I can use to connect my arduino uno r3 to alexa?
@stone dirge and you are matching the 115200 on the Arduino IDE and in the code ?
yes, i think, upload speed is set to 115200
Hmmm and if you go back to the serial port it still has an active connection?
Hey there, I am testing out low power programming on my Feather Lora, (rather unsuccessfully), and saw Ladyada using a usb power analyzer. It was an expensive one, but really handy. I was wondering if anyone knows of cheaper options or even DIY options to get the same capability to see a timeline of power usage via the USB port, or otherwise.
is there a way to encrypt or hash using arduini code?
is there a cryptography library?
A quick search turns up https://www.arduino.cc/reference/en/libraries/aeslib/ for example.
The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.
If you have a favorite portable C/C++ library, that can probably be used without a lot of trouble too.
I have a 5v 3+amp PSU powering a dozen servos, is it safe to also connect this to the gnd and vin of the arduino to power the arduino? I know the arduino won't draw more than it needs but the servos wont then draw too much power from the arduino, vin is only an input?
On most Arduinos, VIN wants 7-12V, though you can also feed it 5V directly on that pin instead. If the servos overwhelm the power supply, it could brown out the Arduino, but it should otherwise be safe.
Thoughts on if In best practice he should also have a diode since there are servos (motor) ?
That's a good question, and I'm not sure. I haven't generally seen that needed with servos, but hopefully someone with more insight can provide a definitive answer.
Small servos can often benefit from a decent sized electrolytic cap across the power leads.
Haven't really seen a snubbing diode needed with them, but it's always a possibility.
is the only way to get a degree symbol (°) in the Adafruit GFX library basically to draw it manually any time i need one when using the classic font?
With the TFT library, I can use \xf7 to get the degree symbol, that might work with the GFX library too.
thanks, i'll give it a shot, typing the symbol into the IDE might be doing some weird unicode one instead of the OG ascii one
Yeah I tried using VIN but it does just cause brownouts. I'll have to figure something else out
I'm trying to play audio off a Seeeduino XAIO, having no luck with circuitpython so far. Also can't do pcm playback with arduino the way I can with a regular arduino chip. Any recommendations on getting audio playback working on this chip?
I have two STEMMA Soil Sensors that I just got from Digi-Key and using the sample code I get pretty much 24-26C on the temp, and a solid 65535 no matter what I do for the capacitive measurement. Anyone have any idea what is wrong? Could both sensors be bad?
What pin on my Feather M0 should I be using to drive my strip of NeoPixels?
Hello, i have an infrared sensor. i connected it to analog pin 0. i used the following code with it to give me the distance. when i put my hand close to it, it gives me 165. when i dont have anything in front of it, it gives me 160. I also tried to adjust the middle distance manipulator but did not make a difference. is this what its supposed to do?```
#define IR A0
int Obstacle;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(IR, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
Obstacle = analogRead(IR);
Serial.println(Obstacle);
delay(500);
}```
What's the specific sensor?
ill give you a pic
A part number would be more useful.
where do i find that?
Did you just find it on the side of the road? I presume you bought it somewhere where it was described as a specific sensor device.
Gotcha. So I guess you'll just need to experiment with it, since there's no way to know what it's supposed to do without knowing what it is.
🤷
i do not know either
Sorry, I'm the sort of person who reads datasheets and designs things to work that way. I'm not the right person to try to get junkyard gear up and running...
okay
ill try and find a way to see which type it is
can i DM you when i find which type it is @cedar mountain ?
I have one of those
The infrared sensor. I don't know what it is called, but I know I got it from a mixed bag kit and I should be able to track it down and find the parts list, give me a few minutes
I found an identical sensor in an Elegoo sensor kit, but it doesnt have a part number- simply listed as 'tracking' sensor. Sorry :/
can you please test it with the code above and 3 wire connections and let me know if it gives you similar values?
please?
Yeah sure
this is my connections
im not sure if the connections actually worked cause i never tried it before
I got very different results
like what?
My understanding is that this sensor is not meant to sense distance, only proximity
Meaning itll report one value if there is nothing in front of it, and another value if something is
Not proportional to its distance from the sensor
okay
I got a value of 1023 when nothing is in front of it, and about 23 when blocked by my hand
The pot in the middle is used to adjust sensing distance
i already tried adjusting it
The red light should not light up when nothing is in front of it
i know
If it's lighting up all the time you have to turn the pot counter clockwise
If it stays on regardless then something must be wrong with the sensor
okay
ill try that
i turned it all the way
not working
led on
i think its not working
anyways thank you so much
No problem, sorry you couldnt get it working
Could be too much external lighting? I don't know
Hey guys, is it possible to get an average value from an analogue input if i measure it for 10 milisec?
I notice in the plotter the value isnt stable so i want to get an average to work with
You can always calculate the average yourself.
k example, does this work?
x = (analogRead(0) + analogRead(0) + analogRead(0) + analogRead(0) + analogRead(0) ) / 5);
Is my Arduino gonna take each reading of the analogue input seperatly over time or is it gonna be filled in with the same value
You could do it in a loop with a small delay.
that is A solution
im trying to figure out how long it takes for the arduino to measure a single analog reading
like, is the arduino fast enough to give me the absolute min val and max value of an analogue reading from a sensor when i touch it. Can i count on it to be accurate? because my plotter shows me a good representation, but if i do the same in the monitor and compare the numbers it looks like it doesnt get the same details
If the signal changes from high-to-low-back-to-high in between two calls to analogRead(), you wouldn't read the low value.
yeah i understand that, but is there a way to figure out the speed it can read it out?
Should be in the IC's data sheet.
You could also create a loop that runs for X ms:
long count = 0;
unsigned long startTime = millis();
while (millis() - startTime < 10) {
int value = analogRead(0);
count++;
}
Serial.println(count);
thx, gonna check it out
around 9 measurements a milisec, if ppl wanted to know
Anyone know how to creqte qn unknown sized array. I need an array to stock ints in, but i can never know how many it will be at start of code?
if you need not one reading but continuous stream of readings, common approach is using low-pass filter:
float averagedReading=analogRead(0);
while (true) {
averagedReading=0.7*averagedReading +0.3*analogRead(0);
Serial.print("New reading: "); Serial.println(averagedReading);
}
numbers 0.7 and 0.3 can be changed
You can just create a pointer like c int * arrayPointer; to an array of ints, then use malloc() when you know how many ints you need (but storage on an Arduino is scarce, and malloc isn't very efficient)
You'd assign it with something like ```c
arrayPointer = (int *) malloc(num_ints * sizeof(int));
If I have a bunch of "if" statements, and I have an "else" statement at the end of my program, how would I address all the variables in the parameters in my "if" statements to tell the "else" loop to run if they're all false?
There are two common patterns here:
if (testA) {
...
} else if (testB) {
...
} else if (testC) {
...
} else {
... // runs only if all of testA, testB, and testC are false
}
-or you might be after-
if (testA) {
...
}
if (testB) {
...
}
if (testC) {
...
}
if (!testA && !testB && !testC) {
... // runs only if all of testA, testB, and testC are false
}
In the first case, only the code for the first test that is true will run. In the second, any code for a test that is true will run, and the last one only if all were false.
If you want to do the later, but the testX things aren't simple variables (they are expressions), or there are many of them, and you don't want to repeat all that in the final if, you can do this:
bool doDefault = true;
if (testA) {
doDefault = false;
...
}
if (testB) {
doDefault = false;
...
}
if (testC) {
doDefault = false;
...
}
if (doDefault) {
... // only run if any of the above didn't run
}
Hope that is what you were looking for, @cunning reef
Yes, the second one is exactly what I want to know. Thanks!
if you need not one reading but continuous stream of readings, common approach is using low-pass filter:
float averagedReading=analogRead(0); while (true) { averagedReading=0.7*averagedReading +0.3*analogRead(0); Serial.print("New reading: "); Serial.println(averagedReading); }
@vivid rock
Thx im gonna give it a try
You'd assign it with something like ```c
arrayPointer = (int *) malloc(num_ints * sizeof(int));
@north stream thx for clarifying
Is there a clean way to check for the highest measured value of an analogueRead in a certain timewindow. I now check if my current value is bigger than previous and keep doing that
That's how I do it
yeah i figured, but there might have been some function that does it for me i dont know bout
Would using an arduino to make a controller using HID be the same as a regular controller?
qucik question... if i connect a LED to a 3.3V of my arduino.... do i have to put a resistance to protect my arduino ? (the LED was previously powered by 4.5V aka 3*LR41 battery)
Er, you need a resistor to protect the LED.
At least a 20ohm resistor at that
If it’s blue/green LED. Probably a 100ohm for red/yellow
Can I use any bluetooth receiver board to control an arduino nano with a ps4/bluetooth gamepad? In guides I can find online they use boards with a USB port, and a USB bluetooth receiver. But I would rather use something like the HC-05 because it is much smaller and doesnt require an external receiver.
I’m sure there is a way
Nevermind, I finally got my esp32 working so im moving to that now
I think the biggest issue is you are not setting your data pin in the Arduino code for output
@gilded swift you're talking to me?
Just do pinMode(DATA_PIN, OUTPUT)
Yeah
I’m not aware of FasLED library sets pin mode or not
i dont quite get wwhat yo're saying
sorry, its my firsrduino project
it's my first arduino project*
You’re okay let me look at your code based on the example on the github page
Heyguys, for some reason my leds don't light up. This is 12 second move of my circuit, and this is the code:
#include <FastLED.h>
#define LED_TYPE WS2812B // type of RGB LEDs
#define COLOR_ORDER GRB // sequence of colors in data stream
#define NUM_LEDS 9 // 60 LEDs numbered [0..59]
#define DATA_PIN 6 // LED data pin
#define BRIGHTNESS 200 // brightness range [off..on] = [0..255]
// Define the array of RGB control data for each LED
CRGB leds[NUM_LEDS];
void setup() {
// initialize library using CRGB LED array
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
}
void loop() {
// configure some LEDs by direct RGB level setting
leds[0] = CRGB(255, 0, 0);
leds[1] = CRGB(0, 255, 0);
leds[2] = CRGB(0, 0, 255);
leds[3].r = 128;
leds[3].g = 75;
leds[3].b = 170;
leds[4].setRGB(50, 100, 150);
leds[5] = 0x08FFA7;
FastLED.show();
delay(1000);
}
What can be the problem ? Honestly, i'm outta ideas
Try changing LED_TYPE to NEOPIXEL, and remove color order
Oh and can you put your code between 3 ` on each side so it formats better
and indeed, add in setup
pinMode(DATA_PIN, OUTPUT);
CRGB leds[1];
void setup() { FastLED.addLeds<NEOPIXEL, 6>(leds, 1); }
void loop() {
leds[0] = CRGB::White; FastLED.show(); delay(30);
leds[0] = CRGB::Black; FastLED.show(); delay(30);
}```
Try that code
erase everything and try yours?
Just comment it out
Block comment your entire code, and paste that code in
/** block comment example */
Trying to set up my ESP32 with wifi- I am following this guide: https://create.arduino.cc/projecthub/benjineering/easy-iot-remotely-controlling-esp32-using-an-android-app-99a1dd
I've installed the library they listed, and im trying to compile but I get the following error: "Multiple libraries were found for "WiFi.h""
Have you downloaded the libraries? @formal onyx
The ESPAsync yes, WiFi (should be?) included in the IDE already
Always good to double check
Did you download the FastLED library @celest sequoia
Okay
But yes it is definitely installed, it is available in sketch > include library > contributed libraries
And you’re positive you’re hooked up to D6?
Yeah
Hmm okay
I mean, ive changed the pin to 12
But ive also changed your code
any ideas?
@gilded swift
I’m looking to see what might be wrong
But I think you still might need to add pinMode(DATA_PIN, OUTPUT)
its not my only led strip, as well as arduino
so ifthey are a problem, its no problem at all
Maybe swap them around
@gilded swift there re 2 GND pins,should i connect the ground tothe pin on the D (digital probably?) row or, the one closer to 5V
either ground pin works
Does anybody know if there is a PCM playback sketch that will work on the SAMD21?
hmm
I'm not sure what you mean by "PCM playback" here. The SAMD21 does have an analog output.
Not sure if this should go here or in #help-with-radio, but do you guys know if the receiver in this project can be modified to work with a standard RC transmitter? I'm thinking of doing an RC car project. The receiver is about halfway down the page.
That's unfortunately a completely different radio frequency range and data protocol, so you'd need a different receiver rather than the nRF24L01 used here.
Anyone awake to help a beginner? I'm having trouble with IRRemote library and "USECPERTICK"
I have version 2.6.1 installed for the library
Please DM if you can help
Error message:
In function 'void dump(decode_results*)':
BareMinimum:65:39: error: 'USECPERTICK' was not declared in this scope
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
^~~~~~~~~~~
BareMinimum:69:46: error: 'USECPERTICK' was not declared in this scope
Serial.print (-(int)results->rawbuf[i]*USECPERTICK, DEC);
^~~~~~~~~~~
Using library IRremote at version 2.6.1 in folder: D:\vinhm\Documents\Arduino\libraries\IRremote
exit status 1
'USECPERTICK' was not declared in this scope
also to clarify, I followed a code from https://wiki.keyestudio.com/052043_Super_Learning_Kit_for_Arduino#Project_1:_Hello_World
Project 14: IR Remote Control
I'm trying to figure out the code I would need to do this:
When given a value eg 1.7 , the rounded down value (1), rounded up value (2) and decimal part (0.7) are produced
You can use floor(1.7) to get 1, ceil(1.7) to get 2. I'm not sure if there is a function to get the decimal part, but you can do 1.7 - floor(1.7).
1.7 - floor(1.7) should work right?
Not sure if it works when the number if negative, but if positive it should.
the number will always be positive so this should be ok, thanks for the help @lone ferry
If you want the integral and fractional parts you can use modf: https://en.cppreference.com/w/cpp/numeric/math/modf
I'm looking to crossfade between 2 audio sources, but have it so the crossfade value can be any float. For example a crossfade of 0.5, would fade evenly between source 1 and source 2, while a crossfade of 42.5 would also fade evenly between 1 and 2.
okay I've figured it out : )
@stone dirge I'm guessing those instructions were written for an earlier or different version of the IR remote library. The current Ken Shirriff / z3t0 version appears to use MICROS_PER_TICK instead of USECPERTICK.
@storm harness - I'm curious what you came up with here... I'm not sure I can make sense of a function where crossfade values of both 0.5 and 42.5 make sense.... out of what range?
I mean - how could BOTH of those values mean an even fade?
ammount = ammount - (int) ammount;
//convert to modular number space
if(ammount < 0.5)
{
gain1 = ((-2 * ammount) + 1);
gain2 = (2 * ammount);
}
else
{
gain1 = ((2 * ammount) -1);
gain2 = ((-2 * ammount) +2);
}
}
I'd guess those are rates/times
The factors of 2 in the above code seem weird to me. Ordinarily I'd expect to see just x and 1-x if x is a crossfade ratio.
So, considering just the fractional part of the float, you want from 0 to 0.5 to fade from all gain1 to all gain2, and then from 0.5 to 1.0 you want to fade back from all gain2 to all gain1?
(that is what your code does, I think)
yeah, you're correct
I couldn't come up with a way to crossfade except that
other ones dont repeat nicely
What are you trying to get? From 0.0 to 1.0 gives fade from gain1 to gain2?
Oh - you do want it to repeat
yeah that is what i was trying to do
okay - you're good then!
Note that you can also do this with a sine / cosine function. Then the amount of crossfade isn't linear but that may actually look nicer.
You might also consider doing an even/odd function, where 0 is source A, 1 is source B, 2 is source A, etc. That way every 0.5 is an even mix.
this is for wavetable interpolation not for audio, so it has to be done linearly.
@cedar mountain while it is a bit of a botch fix, i just multiply the input by 0.5 and it works.
@north stream Thank you, I will try doing a little research on micros_per_tick
@north stream Would it be a simple as replacing USECPERTOCK with MICROS_PER_TICK?
quite possibly
thank you, i appreciate the help
Another question, if anyone is available to help. I have an ESP-01s (https://www.microcenter.com/product/615098/inland-esp-01s-usb-to-esp8266-wireless-adapter-module) I bought from micro center, I have the board installed into arduino ide (http://arduino.esp8266.com/stable/package_esp8266com_index.json) and I am using the included USB adapter in UArt mode to upload code and Flash download mode to monitor the program. My question is:
- I am not getting a response when using the AT command with the BareMinimum program. Any thoughts
I have the monitor set to Both NL & CR at 115200 baud rate
I also have the upload speed set to 115200 in the ide
- I also tried uploading and running the Blink example, which worked perfectly.
- I don't know why I used numbered bullet points as I only have one question haha
This is what I am getting in response to the AT command:
does anyone know of any examples of playing audio with a PyPortal using ARDUINO? [Update - found some info on the adafruit website - looks like they don't suggest using the audio with Arduino... so maybe I'm gonna be forced to build this project in python after all) 🙂
im using the adafruit feather motorshield, im struggling with the sample code, when the motor is triggered im wondering how to control how long it runs
my Motor->run(FORWARD)
im trying to use the feather to connect to adafruit.io to open and close my chicken door :\
ive got the hardware all figured out 😛
does anyone know of any documentation that could help?
The simplest method would be to use a delay, then stop the motor: myMotor->run(FORWARD); delay(1000); // 1 second myMotor->run(RELEASE);
1000 is one second, awesome!
milliseconds, duh
Thank you!
i might be able to figure this out!
i got it working and connected to adafruit.io!!
im missing something though
it was " if(data->toPinLevel() == HIGH)"
i dont really understand the data conversion from the io.
It looks like you have two problems. One is you're handing in a pointer to an object, but checking if it's 0 or 1 (unlikely: you probably want to access an instance member or call a method). The other is that you're using the assignment operator = instead of the comparison operator ==
I think i cant have my adafruit.io switch say open/closed it has to be 1 or 0
but it doesnt like the second IF
is what i had from the sample
:\
I don't understand why you changed it.
i dont understand the code :{
@cedar mountain thanks! Do you know of any projects that are compatible with a standard RC transmitter? Most of the ones I see are designed like that one, with a custom transmitter.
i changed it back
*sweat
oh wait it compiled this time!
how does it change 1 or 0 to low or high
The Arduino code has definitions for "LOW" and "HIGH"
@bleak raptor ordinary RC protocol is a special case of PWM.
Alright 🤔
There's a nice writeup on it here https://www.pololu.com/blog/17/servo-control-interface-in-detail
oh sorry i mean it seems to run both instances of the IF
it does the 1 task then the 0 task
i dont need pinlevel, can i just do a IF that checks the feed data?
¯_(ツ)_/¯
can i use IF and a specific value like 1, 2 or 3, not high vs low?
yes if (data == 3) ...
hmm it complained about that when i did it
i think i fixed it by adding int reading = data->toInt();
data is still a pointer to an instance, not an integer. Comparing or casting it to integers is unlikely to do what you want
what is the type of data?
AdafruitIO_Data* I see, so it is a point to something
ah - so, AdafruitIO_Data is "opaque" in the sense that you can't just simply reach in and grab the low level data... You must ask it for the data.
so something like if (data->toInt() == 2) ...
Now, it turns out "to be helpful" a value received this way can be coverted to any number of basic types.
You can call:
toBool()
toInt()
toPinLevel()
toDouble()
toRed()
....
There are a zillion of them. Now, which one to use depends on what data you think you are expecting. If you are expecting an integer - than use toInt().... if you are expecting a pixel color, try toNeoPixel()
If you are expecting a boolean value, you can use toBool()... or the even cleaner isTrue() and isFalse() -- like so: if (data->isTrue()) { .... }
Of course, the data sent by the other side will have to be in some compatible format.... So if the other side of the project is sending HIGH and LOW, then by all means use toPinLevel() -- If the other side is sending integers as a sort of stand in for commands ("1 means close, 2 means open, 3 means flash the lights, 4 means dispense kitty treats, ....") --- then use toInt() and test as we suggested.
Hope that makes some sense.
thank you all so much!
i think i got it!
i changed the if statement around, it seems to work better too
if (action) else (non action message)
im testing it in the coop now
in the coop... I suppose I should have said "4 means dispense chicken treats...." 😁
this works well 😄
working so far
😄
whats the worst that could happen....
hi everyone, i'm new here
i need some help about arduino code ( i'm still a beginner )
i'm doing a project using:
LCD 16x2 ( changed from LCD keypad shield )
AS608 Fingerprint Sensor
4 Relay 12volt
arduino nano
4 buttons
and 4 solenoid locks
i'm sorry if i'm using the wrong chat
and here is the code:
okay - what's the help you need....
(first thought: that is a lot of code for a single file.... should probably be split up)
i'm a beginner so i don't know how to split it up
anyway
i shouldn't have put that one first but
i was using an Analog pin to control 4 buttons
and change the display screen on LCD up, down, right, left
but now i need to changed it to a different pins ( digital pin )
I see, your problem is here:
int up_hit = digitalRead(up);
int down_hit = digitalRead(down);
int right_hit = digitalRead(right);
so i need help to make the button do the same thing as the analog pin
You see - when this code runs - the button states are read once, and the value saved in each of those three variables.
Later - when you this code runs:
int evaluateButton(int x) {
if (right_hit == LOW) {
x = 1; // right
} else if (up_hit == LOW) {
x = 2; // up
} else if (down_hit == LOW) {
x = 3; // down
}
return x;
}
i want to clarify that
It is not testing the current state of the pins, but instead, the state of the pins at the time up_hit etc. were initialized.
this is the original one:
readKey = analogRead(0)
button = evaluateButton(readKey)
int evaluateButton(int x) {
int result = 0;
if (x < 50) {
result = 1; // right
} else if (x < 195) {
result = 2; // up
} else if (x < 380) {
result = 3; // down
} else if (x < 790) {
result = 4; // left
}
return result;
}
int evaluateButton1(int x) {
int result = 0;
if (x < 50) {
result = 1; // right
} else if (x < 195) {
result = 2; // up
} else if (x < 380) {
result = 3; // down
} else if (x < 790) {
result = 4; // left
}
return result;
}
that was not right, either. (assuming that that is at global scope)
also, this line is not doing what you think:
button = evaluateButton(readKey);
So, let's go back to
int up_hit = digitalRead(up);
ok
What this line of code means is this: "When this line is executed..... call the function digitalRead with the argument up which will read the state of the hardware pin and return a value, HIGH or LOW. Then create a variable named up_hit and initialize it's value to that result."
Let's start with that - is my description clear?
Good. Now, if this line were in a function, like this, say:
void loop() {
int up_hit = digitalRead(up);
...
}
Then it would be executed once each time the function was called.
But in your code, that line is outside of any function. We say this is "global". And that means the line code is executed once at the start of the program (somewhat before setup() is called).
It will only ever be called once, and in this case before you have even set up the pins in setup()!
Does that make sense?
yes
So - rather than writing
if (right_hit == LOW) {
you should be writing
if (digitalRead(right) == LOW) {
which will execute the call to digitalRead() each time that if statement is executed, thus reading the pin afresh.
Do you see how the existing code wouldn't ever look at the pin after the start of the program.... whereas the second version will re-read the pin each time?
hmmm.. yes
It is important to get the "operational model" of how C code works in your head: Saying x = .. some thing else ...; is not like regular math: Later when you use x, it is not the same as the "some thing else" - At the time the assignment (x = ...) was executed x was set to the result of executing the some thing else.... then later when you use x, you are using that stored value. No matter if "some thing else" would now be different, x is the stored value until another assignment is executed.
Of course, if the program executes x = 3 + 4; Then later, using x is exactly the same as using (3 + 4) -- because the value of 3 + 4 can't ever change.... The difficulty comes in with expressions that can: digitalRead() depends on the state of hardware that can change. millis() depends on the state of timers... and in x = 10 * y; the expression 10 * y might change if y changes!
void setup() {
int y = 5;
int x = 10 * y;
Serial.begin();
while (!Serial);
Serial.println(x);
y = -2;
Serial.println(x);
y = 10000;
Serial.println(x);
}
All of those print 50... because the value of 10 * y was evaluated and stored in x on that one line at the top... no matter that y changed later... x was only assigned to once.
Does that help clear up what was wrong with the way the pins were read?
yes i understand
great!
okay - one more thing
You have code like this:
button1 = evaluateButton1(readKey1);
and later this:
int evaluateButton1(int x) {
if (right_hit == LOW) {
x = 1; // right
} else if (up_hit == LOW) {
x = 2; // up
} else if (down_hit == LOW) {
x = 3; // down
}
return x;
}
ye, i wasn't understand how the original code works
since everything was putting all of it into a variable name: result
When you pass a value like that (readKey1) to a function declared like that (int x) -- the function cannot change the value of the variable in the caller. In this case, evaluateButton1 cannot change readKey1.
Okay, It should look like this:
button1 = evaluateButton1();
and
int evaluateButton1() {
int x;
if (right_hit == LOW) {
x = 1; // right
} else if (up_hit == LOW) {
x = 2; // up
} else if (down_hit == LOW) {
x = 3; // down
}
return x;
}
which can be simplified:
int evaluateButton1() {
int x;
if (right_hit == LOW) {
return 1; // right
} else if (up_hit == LOW) {
return 2; // up
} else if (down_hit == LOW) {
return 3; // down
}
return 0;
}
(er - replacing all the right_hit like things with the digitalRead function calls as described above)
Also evaluateButton and evaluateButton1 are identical - no need to have both!
okay - bed time for me... Good luck!
Good morning all. Need help with adding to an array " char txtMsg[200];"
I have a RTC and I wan to add the .hour + .minute + .second at the time of the message before sending
too many arguments to function 'char* strcpy(char*, const char*)' << Is my error
strcpy(txtMsg, "cat" + clock.hour, DEC); < is a snip of the code line
RTC is the DS1307
Several things are going wrong there, I think. For one the DEC parameter is only used in the Arduino print routines, not the general C str library calls. The use of + is likely not doing what you expect with character arrays, since it's actually performing pointer arithmetic. And strcpy doesn't concatenate, just overwrites... you'd want strcat for that instead.
But it looks like you would want sprintf() in general for this kind of operation, where you want to construct a string from placeholder text plus numeric variables.
okay looiing into strcat() ughhh Not the best with Strings/Char/Arrays etc
try something like:
snprintf(txtMsg, sizeof(txtMsg), "cat%2d.%02d.%02d", clock.hour, clock.minute, clock.second);
Some notes on this:
- always use
snprintf, neversprintf(makes sure you don't overrun your buffer - the
%2dmeans a two character wide decimal field,%02dmeans the same, only zero padded,%dwould be just decimal, as small as needed - replace the
dwithxfor hexadecimal - I believe that not all Arduino core libraries have a full implementation, and may not support all the features of the
--printffamily of functions... though they will support the above.
ahhh it worked
now if I want to put a space after "t" in "cat" do I need to put a "%" someting before the %2d ? I just can't put a space like this "cat %2d......."
just put in a space!
The format string is just copied into the buffer, but replacing each % field descriptor with the next argument from what you passed.
Works .. just seems like it takes longer to send
actualy, the same.. must have been a random delay by the cell network
I'm not sure where or how you're sending it - but the difference between using snprintf and other ways of building up that string are minuscule.
It is working just fine now, Appreciate the help.. Have it exactly doing what I want
If you want to learn more about that function, and the "mini-language" for format strings, see here: https://en.cppreference.com/w/cpp/io/c/fprintf
Yeah that would be very helpful.. I was using "sprintf(txtMsg, "%02d:%02d:%02d", clock.hour,clock.minute,clock.second, " cat");" Before you jumped in to help
It was not printing 'cat' but did the time
yes, you'd need a %s specifier if you want it to include a string from the argument list... but if that string is fixed (like "cat") you might as well just put it in the format string.
Gotcha... Off to read the link you sent now and getting some lunch .. Thanks again @obtuse spruce It is wokring 100% perfect
welcome
@obtuse spruce snprintf looks handy, I wonder what Arduino Serial.print() uses under the hood
I believe that the Arduino cores have a Serial print functions are all just hard coded for each type. The Adafruit cores add Serial.printf which uses vsnprintf under the hood.
(the v version is just variant that allows one var-args function to call another)
Hello this is my firs message in this server, so first of all thanks, and sorry if my English is not very well.
I have some issues working with the AdafruitIO and the PubSubClient library running on the esp8266. I read in the adafruit webpage that is compatible.
The connection is correct because I can see the information published with the esp8266 on the dashboard, and I receive correctly the messages from the adafruitIO to the esp8266. The problem is that after a little time, appears “failed, rc=6 try again in 5 seconds”, then reconnects again, and repeat this situation. Sometime reconnect immediately, and sometimes no.
Someone know what the problem is?
Thanks
Do you have a link to which fork of pubsub youre using? The usual version does not have a state value of 6
i am starting out with Arduinos and i know a a little bit about programming and is there any good tutorials on programing a Arduino
You can start with things like this https://learn.adafruit.com/lesson-0-getting-started
Do you have a link to which fork of pubsub youre using? The usual version does not have a state value of 6
@stuck coral i installed the library directly from arduino library manager
but i read on som github issu that the 6 will be coming from the adafruit broker, not the client
I changed the clientID and for now is working....
@pulsar yacht good catch. That happened to me too. Gotta use a real unique I'd when on a server with many other users.
@pulsar yacht good catch. That happened to me too. Gotta use a real unique I'd when on a server with many other users.
@wraith current It's strange because i have connected only one esp8266, but now its working...
@pulsar yacht my point is that you're not the only one connecting to that mqtt broker
@pulsar yacht my point is that you're not the only one connecting to that mqtt broker
@wraith current ahh okay. I thought that i was the only because i was working in my account with only one esp. Thanks!
@pulsar yacht the mqtt broker keeps track of every device based on it's id.
Can anyone help me with setting up a circuit for controlling an led with my esp-01s?
I have 3.3v and ground from mega 2560 going to vcc and ground of the esp-01s
gpio1 from esp-01s going to positive of led and negative of led going to ground
you'll need a current limiting resistor in series with the LED
220 ohm ok?
@reef ravine can you confirm that the gpio1 is pin 2 on the esp-01 module? Im not sure
220 would give you about 5 mA
it looks correct, here is a link with pinouts about 1/4 down https://circuits4you.com/2016/12/14/esp8266-pin-diagram/
would you recommend using a smaller or bigger resistor?
what color LED?
red
Red/yellow on 3.3V would need a larger resistor than blue/green. 300-330 for red/yellow, 220 is good for blue/green
The forward voltage drop of different colors is different
1k or 10k?
btw i am very much so a beginner at this, so sorry for the lack of knowledge
For red then you have 3.3v - 2.0v = 1.3v. 1.3v / 220 ohms = 6 mA
ok so using a blue led with 220 ohm would be ok?
You could do 220 on red, it just might be brighter than you need
this is purely experimental, so it doesn't need to be red
6mA across a red is considerably brighter than 6mA across a blue
im just trying to learn
Try out both and see which you like best
the key point is you need to limit the current being drawn from a pin on any MCU
ok so trying it with neither the blue nor red work with the 220. I'm assuming that I don't have it setup right
do you have a multimeter?
yes
i have the small pin on the led connected to the resistor which is going to ground
the longer pin is going to the gpio1 pin on the esp01
the shorter lead is generally negative so that sounds correct
are you using a breadboard?
yes
the breadboard is being powered by a mega2560 because i don't have a seperate power supply to power it
if you measure GPIO1, is it high?
positive on the breadboard is going to 3.3v, and ground to ground
sounds like a good way to power the ESP01
does it go to 3.3 if you remove the LED and / or the resistor?
for that matter, is Vcc to the ESP actually 3.3v?
i'd measure from Vcc to ground at the ESP and make sure it is being properly powered
ok, if unconnected then GPIO1 should be 0 or 3.3v
if it is short you can paste it here, use the "backtick" to format it like this
are you connected via serial to the ESP? it uses GPIO1 for serial TX
use pastebin.com and post the link here
there is also a config tab if you need to see that
its an adafruit io example btw
the coding was uploaded to the esp via a separate adapter
first thing i notice is you have #define LED_PIN 2, "which pin is which" varies from board to board
I honestly am unsure
try changing the define to pin 3 and connect to GPIO2
ok i'll do that now
pin 2 is being used the serial interface
the ESP01 seems to have a limited number of IO pins compared to other variants
even though im just using the mega as a power supply, do i need the rx tx pins connected? or is that just for uploading?
Tx and RX are used for serial programming, using the mega as a convenient 3.3v power supply is fine
#define LED_PIN 3 means "substitute 3 wherever LED_PIN appears in the code"
ah i see
it's handy so if you decide to use a different pin you only need to change your code in one place
ok uploading now
ok so now gpio2 is pulling 0v but I cant seem to get it to pull high
the mega is not outputting power...
bad connection?
no im just dumb... lol i had the multimeter on ac... power is fine
so does pin 3 toggle between 0 and 3.3v?
no only 0v
if you move the LED to Vcc, does it glow?
yes
what do you mean?
are you using the Arduino IDE?
yes but the esp is not currently connected to that
im trying to control it through adafruit
sorry i probably should have led with that
i did confirm that it is connected
using the included usb adapter
the serial terminal will show diagnostic messages (all the "Serial.print" statements)
so then should i connect the tx rx on both boards to eachother?
what did you mean by "included usb adapter"?
thats how i uploaded the code
ok, then after upload you transferred to the breadboard?
yes exactly
it might pay to wire the adapter to the breadboard so you have power and serial from it, then you don't need the mega for power
honestly have no idea how to even get started on that lol
you would wire it one to one, the pins on the ESP to the corresponding socket on the adapter, all you need are Vcc and ground, Tx and Rx
oh i see
that way you still have access to the pins and you can use the serial monitor to help debug
i'll go ahead and try that now and i'll get back to you
come to think of it, how are you mounting that module on a breadboard? either rows or columns will be shorted....
i have male to female leads
ah, ok
ok all connected
you have Serial.begin(115200); so the Serial Monitor needs to be set the same
i have the monitor set to "Both NL & CR" at 115200 baud
Monitor reads:18:29:09.763 -> ⸮.........
18:29:16.970 -> Adafruit IO connected.
18:29:17.110 -> received <- LOW
ok, now send a HIGH (however you are doing that with your IoT provider)
ok, so my guess about "which pin is which" was probably wrong
should i move it around to different pins to check?
on these boards you need the pin definitions, as physical pins and GPIO pins may be different
see if you can find the pin which toggles with the DVM
dvm?
Digital Volt Meter
https://components101.com/wireless/esp8266-pinout-configuration-features-datasheet, looks like only pins 5 (GPIO0) and 3 (GPIO2) are available for your use
serial says it's toggling, so the pin specified must be wrong
this module seems a bit "pin short", some more info is here https://www.instructables.com/id/How-to-use-the-ESP8266-01-pins/
i tried on and off with all the pins, they all stayed the same
I generally use a Wemos D1 Mini, about the same size but more pins are broken out
Yeah, i bought this with minimal research.
see this, about halfway down http://www.forward.com.au/pfod/ESP8266/GPIOpins/index.html
looks like you can use GPIO0 and 2, but they are normally HIGH and your program needs to set them low
so, to my understanding if i were to switch to pin 5 it should work?
because it pulls from low to high rather than high to low like on pin 3
correct me if im wrong
or switch HIGH and LOW on the code
i'd stick with pin 3 (GPIO2) but change the logic in your sketch to set the pin LOW rather than HIGH
ok let me try that
if(data->toPinLevel() == HIGH) Serial.println("HIGH"); else Serial.println("LOW");
switch all of those correct?
looking at it, just reverse the LED circuit, Vcc > LED anode, LED cathode > resistor > pin 3
looks like pin 3 will always be HIGH, sending LOW would then turn on the LED
flip it and tie it to Vcc rather than ground
in this case 3.3v is Vcc
OK that makes sense
Vcc is a generic term for "positive power supply", could be 3.3v, 5v, 12v, whatever
ok, i have a lot to learn lol
ive only ever taken 2 physics classes, where we barely touched on circuits and 1 c++ class, which was 10 years ago...
i think Mr. Newton was still teaching physics when last I had a class in it lol
ok so that didn't seem to work
if you measure pin 3 does it ever go low?
im getting about 2.3v on pin 3
double check that the anode of the LED is going to Vcc, maybe it's backwards
Yo can anyone help me start out with arduino
@reef ravine ah i had the led flipped
ok, I have to go, good luck with it!
hey thank you so much for the help
I really appreciate it
i'll just keep messing around with it. have a good one
does anyone know other resources for heritage arduino ide -- micr$oft site not offering. win 8.1
The previous releases are available on the download page https://www.arduino.cc/en/Main/Software
NeoPixel matrix
Hello is there anyway to rotate the way text scrolls on a matrix i need it to scroll landscape but at the moment its scrolling portrait and i am unsure on how to do this if anyone can help thanks
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
I think the GFX library supports various ways to orient and scroll text
it think it has but i am unsure on how to use it
Some of the examples should show how to do things like that
@broken summit - do you want the text rotated, or just the scrolling to be vertical?
If you want drawing to be rotated, use this:
matrix.setRotation(1);
If you want it rotated "the other way", use 3.
Just do that one in setup()
@obtuse spruce thanks this works
i am geting this error avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
Hey all, I’ve been using an attiny85-based board similar to this one https://www.adafruit.com/product/1501
It’s great but it doesn’t have a lot of pins and I’m looking for something that has a lot more pins, such as the teensy https://www.adafruit.com/product/4323
Is there something in between? jumping all the way from an attiny85 to a teensy is massive overkill (I don’t need 90% of what the teensy offers) so I’m just trying to figure out if there’s a better option
Deprecation Warning: The Trinket bit-bang USB technique it uses doesn't work as well as it did in 2014, many modern computers won't work well. So while we still carry the Trinket so ...
For reference this is what I’m using currently, I have the lipo battery connector and micro USB port desoldered so I can shove it into a much slimmer space https://www.olimex.com/Products/Duino/AVR/OLIMEXINO-85S/open-source-hardware
I feel like this might be a suitable board but it’s out of stock, forgot to mention it https://www.tindie.com/products/femtoduino/femtousb-atmel-arm-cortex-m0/
@ivory gorge arduino Nano is between those two
Ooh that has an utterly delicious number of pins
I went to the dev boards section of Adafruit and started opening all the potential products in new tabs and quickly realized I would have hundreds of tabs whoops
@woven mica looks like this is the closest thing from Adafruit? https://www.adafruit.com/product/2590
Or perhaps https://www.adafruit.com/product/2010 ?
Make your Arduino-based project tiny and with the Adafruit METRO Mini! The METRO Mini works great with the Arduino IDE, and runs the ATmega328P at 16MHz so it is pin-compatible with Arduino ...
Yes the metro mini is like Nano
having some trouble with my Matrix here 16x16 where when it display an image, every other line is reversed! (maybe zigzag)? how do i fix this in the code so it display correctly?
what is the best library to use a Matrix? mine is 16x16 (256) WS2812B 🙂
I don’t have much experience with that but something tells me your library will have an option for row/column vs zigzag
currently im just using FastLED library
i dunno if i have to use like FastLED_NeoMatrix lib or :S
https://github.com/FastLED/FastLED/issues/35 it looks like fastled added that 6 years ago
never had this error befor, what does it mean?
src\bitmaps/smb.h:41:1: error: narrowing conversion of '4278190080u' from 'unsigned int' to 'long int' inside { } [-Wnarrowing]
It means a variable is being converted from a more precise one to a less precise one
In this case, the value is large enough that it can affect the sign bit and cause problems
how do i fix that exactly? :S
a value of type "const long *" cannot be used to initialize an entity of type "const long"
The first warning was because you should use const unsigned long. The second warning I guess is from using PROGMEM.
Also, the values given (like 0xff000000) won't fit in a const long
weird that that would give error given im trying this -> https://github.com/joshgerdes/arduino-led-matrix/blob/master/arduino-led-matrix.ino
there is no issues posted either on that github
Either nobody has tried it, they ignored the warnings, they're running a different compiler configuration, or they didn't bother to post issues
using progmem that means i can't alter the bitmap/image right?
It depends on when/how you want to alter it.
i have python program running that takes a 16x16 image converts it and then sends it to the ESP32
hey, I'm trying to program an esp8266 board (Feather Huzzah!) from ubuntu 19 (linux kernel 5.3.0-63), and I'm having trouble getting the drivers to work, or at least getting it recognized by Arduino. I've been following this tutorial (https://learn.adafruit.com/adafruit-feather-huzzah-esp8266?view=all#using-arduino-ide) and I did the driver installation but it's still not showing up in the Arduino application. Checked with a cable i know supports data transfer, and I got it working on windows, did I do the driver thing wrong? (Also doesn't appear with lsusb)
so i need to "fix" this
argument of type "long" is incompatible with parameter of type "const long *"
void drawBitmap(const long* bitmap) {
FastLED.clear();
bool LTR = true;
for (int i = 0; i < NUM_LEDS; i++) {
if (LTR) {
for (int j = 0; j < COLS; j++) {
leds[i + j] = pgm_read_dword(&(bitmap[i + j]));
}
} else {
for (int j = COLS - 1; j > 0; j--) {
leds[i + COLS - j] = pgm_read_dword(&(bitmap[i + j - 1]));
}
}
i = i + COLS - 1;
LTR = !LTR;
}
}
void drawAnimation(const long* bitmaps, int s, int delayTime) {
for (int i = 0; i < s; i++) {
drawBitmap(bitmaps[i]); // This is the error
delay(delayTime);
}
}
Try: const long** bitmaps
ok that error gone
@lone ferry ty
then there is this @lone ferry
https://pastebin.com/3UhFL7vh
error given
a value of type "const long *" cannot be used to initialize an entity of type "const long"
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
What line?
const long DigDugTaizo[DigDugTaizoSize] = { DigDugTaizo01, DigDugTaizo02 };
const long DigDugTaizoShovel[DigDugTaizoShovelSize] = { DigDugTaizoShovel01, DigDugTaizoShovel02 };
const long DigDugPooka[DigDugPookaSize] = { DigDugPooka01, DigDugPooka02 };
const long DigDugFygar[DigDugFygarSize] = { DigDugFygar01, DigDugFygar02 };
these
Pretty sure these should be const long * with the *
Those 32-bit quantities may still cause problems in a signed 32-bit variable.
Yes, it should really be const unsigned long *.
that one gone, ty @lone ferry 🙂
now this error
src\bitmaps/galaga.h:41:1: error: narrowing conversion of '4278228887u' from 'unsigned int' to 'long int' inside { } [-Wnarrowing]
what was that again?
What we just said 😉
Yes, but also with static still in there.
first error
narrowing conversion of '4278190080u' from 'unsigned int' to 'long int' inside { } [-Wnarrowing]
second error
a value of type "const unsigned long *" cannot be used to initialize an entity of type "const long *"
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
@lone ferry
@elder hare Everywhere it says const long you need to change that to const unsigned long
Still getting that warning?
Maybe you also need to put UL behind all those numbers then, as in 0xff000000UL. Weird that the compiler doesn't see 0xff000000 as an unsigned long, though.
Easiest way to do this is to copy those lines into a text editor and replace , with UL,. No need to type that all in. 😉
w00t!!! 😛
Ah yes, you need UL behind those numbers indeed: https://www.arduino.cc/reference/en/language/variables/constants/integerconstants/
The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.
never had that befor 😛
It's because the Arduino C++ compiler treats ints as 16-bit numbers, but other C++ compilers use 32-bit numbers.
aahaa 🙂 im using Visual Studio btw
What device are you compiling this for?
ESP32
Hmm, not sure what the sizes of datatypes are for that. But hey, if it works, it works. 😄
not sure it's working still im converting now
@lone ferry the error is still there :S weird
Where?
now it works!
now i just need to figure out how to make FastLED use ZigZag as my Matrix im pretty sure is ZigZag (so every other line is reversed)
on github it says that FastLED has fixed this and implemented this function into FastLED :S but i can't find it
I got this ST25DV16K To "mess around with" https://www.adafruit.com/product/4701
This RFID tag is really unique: it works with mobile phones just like other RFID tags, but you can reprogram it over I2C. The tag shows up as an ISO/IEC 15693 (13.56MHz) chip which is ...
THis is the demo code
It tries to compile and has issue with this part of the code "#error define the pin and wire instance used for your board"
Also board is a --> #if defined(ARDUINO_B_L4S5I_IOT01A)" Couldn't find anything helpful on a google search
Edit what board is a ARDUINO_B_L4S5I_IOT01A ?
Looks like it's an STM32 Discovery board: https://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-mpu-eval-tools/stm32-mcu-mpu-eval-tools/stm32-discovery-kits/b-l4s5i-iot01a.html
ahhh good find
So just take that part of the code out and define proper pins for GPO. LPD, SDA and SCL?
Feather 328P I know how to find SCL/SDA ... any pins to avoid for LPD and GPO?
Actaully .. reading the product page a 328P does not have enough specs to run it.. will have to use another board
Changing to a https://www.adafruit.com/product/3010
Anyobe able to help with pin assignment ? This is the only M0 I have righ now.. should be fine to use ? I am not doing anything with Wifi just a test of the ST25DV16K
so this is weird
my python script generated this
from this
it is correct and 16x16
however
my ESP32 displays it like this
you see the black LED (off)
only on the blue side :S
and if i flip the matrix / image it follows
This is the function that does it, any error in here that might cause this? :S
void drawBitmap(const unsigned long* bitmap) {
FastLED.clear();
bool LTR = true; // Flips the image
for (int i = 0; i < NUM_LEDS; i++) {
if (LTR) {
for (int j = 0; j < COLS; j++) {
leds[i + j] = pgm_read_dword(&(bitmap[i + j]));
}
} else {
for (int j = COLS - 1; j > 0; j--) {
leds[i + COLS - j] = pgm_read_dword(&(bitmap[i + j - 1]));
}
}
i = i + COLS - 1;
LTR = !LTR;
}
}
For faster help maybe in the help withCircuit python?
ahhh, cool wanted to make sure you had quick help
@elder hare for (int j = COLS - 1; j > 0; j--) { should be for (int j = COLS - 1; j >= 0; j--) {
Probably.
@lone ferry still black pixels :/
at the same place*
hmmm
@lone ferry when i changed for (int j = 0; j < COLS; j++) { this to for (int j = 0; j <= COLS; j++) { this the black spots became green
i = i + COLS - 1; is wrong ... should be i = i + COLS;
AND
leds[i + COLS - j] = pgm_read_dword(&(bitmap[i + j - 1]));
needs to be
leds[i + COLS - 1 - j] = pgm_read_dword(&(bitmap[i + j - 1]));
ack... wait...
fie - hold on, let me give you a clean version of it all at once
void drawBitmap(const unsigned long* bitmap) {
FastLED.clear();
bool LTR = true; // Flips the image
for (int i = 0; i < NUM_LEDS; i += COLS) {
for (int j = 0; j < COLS; j++) {
int k = LTR ? j : COLS - 1 - j;
leds[i + k] = pgm_read_dword(&(bitmap[i + j]));
}
LTR = !LTR;
}
}
@obtuse spruce there we go 🙂
There - I cleaned up several things:
- bump
iin just one place - eliminate the
if, because both branches were very nearly the same - removing repeated code makes code easier. - introduce
kwhich is the only thing that really changes LTR or !LTR: You either go forward or backward on the leds... the rest is the same - used the
?:operator - which forces the code to be clear that the two options are the same kind of thing - we don't want to set an LED in one side of an if and launch kites in the other side - we only want to pick an LED index on either side of the conditional.iflets you do anything on either side,?:constrains the sides to be consistent.
Lastly, this code tried really hard to avoid all the - 1 bits all over the place... they are hard to reason about (I missed several things on my first two attempts to fix the code) - and generally a "code smell" if you have more than one of them in a tight loop like this.
would you look at that 🙂 ty for that one @obtuse spruce 🙂
most welcome
Hi mzero are you able to help with an example code written for a STM32 Discovery board: need it to work on a M0 ... need help with pin assignments
Sure - I can look - which M0 board is it?
Pinout page https://learn.adafruit.com/assets/46250
got it - what the issue / code?
What to assign for // #define GPO_PIN PE4
// #define LPD_PIN PE2
// #define SDA_PIN PB11
// #define SCL_PIN PB10
I have no experience using pin names like "PB11" usally just a raw number, I'm sure you have to be careful with Pins that are resets and whatnot
And don;t see an exact match for a PE2
yes, those are uncommon - but in the CMSIS (the files from the chip maker) - PB11 and PB10 are defined as "pin" 43 & 42 -- but I don't think those are Arduino Wiring pins, but instead, actual pins
And I can't find PE2 at all --- so I'm assuming that the core header files from the STM32 discovery board defines these -- as Arduino wiring pins. I don't have that core... BUT - it should be easy to find the right values for your Feather M0 board
Looks like PA22 and PA23 for SDA SCL
first, the following will probably work on any board:
#define SDA_PIN PIN_WIRE_SDA
#define SCL_PIN PIN_WIRE_SCL
ok cool
those PIN_WIRE_XXX constants are defined to be Arduino Wiring pin numbers --- which each board's core code has tables that map these "pin numbers" to actual pins on the chip - (and ports and bit numbers).
hmm i can't use pastebin here?
I foundout pins 2,4,7,8 look to be all used by the WINC
Now - I'm not sure what GPO_PIN and LPD_PIN are used for
so this is my main.ino
https://pastebin.com/Bwm71aUG
this is the GalagaBoss image array
https://pastebin.com/Fy3gFsvg
why wont it animate :S maybe im missing some small little detail :/
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Same.. I know when the borad came out they had a demo. .. wonder if they plan to post it
It would be helpful to see a wiring of how they had it hooked up too
Maybe the UPDATE() method isn't getting called?
OH - those are just generic pins used to initialize that st25dv library - they aren't used in that sketch at all.
@north stream iforgot myself there xD that was MyFastLEDMatrix.h xD
ohhhh
this is the main.cpp
#include <Arduino.h>
#include <WiFi.h>
#include "MyFastLEDMatrix.h"
#include "MyWifi.h"
#include "MySocket.h"
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.setSleep(false);
FastLED.setBrightness(64);
FastLEDMatrix->SETUP();
MyWiFi->begin();
MySocket->begin();
}
void loop() {
FastLEDMatrix->UPDATE();
MySocket->loop();
}
and yes it gets called
@quartz furnace - at least I don't think they do.... what are you trying to do? Write to a writable NFC tag?
The demo that was show is you take your phone to this board and you can read it by NFC
shown*
You may need to make your update time variable a class member
@obtuse spruce So that leaves it wide open for the pin to use? Just avoid the ones for the WINC chip i.e 2,4,7,8 ?
Okay - so - Does your feather have NFC on it? I see WiFi... but not NFC?
@north stream they are now class members and it still doesn't animate :/ erh what could be wrong
@obtuse spruce So I can't use a 328P due to spec limitations.. this is the only M0 borad I have
So the thought was to test it on that board, just not load anything to do with WiFi
@elder hare - it doesn't animage because drawAnimation simply draws a the bitmaps on top of each other each time it is called from UPDATE
but in the drawBitmap i have FastLED.clear(); that would clear the matrix?
@quartz furnace - but I don't think there is any NFC hardware on that feather you are using.
Is your aim to do something with NFC?
Let me post the board from the site
This RFID tag is really unique: it works with mobile phones just like other RFID tags, but you can reprogram it over I2C. The tag shows up as an ISO/IEC 15693 (13.56MHz) chip which is ...
@elder hare - is your aim, each time UPDATE is called, and it passes the curtime > lasttime check, that it draw one bitmap from the list, and then the next time, draw a different one, etc....
Seems like it has the NFC in the breakout
@obtuse spruce ooooh looking at the serial monitor the ESP32 crashes constantly 😐
@obtuse spruce yes
AH - okay, I missed that you have that
no worries..
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5828
entry 0x400806ac
[DNS] DNS Adress : esp32Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d182b PS : 0x00060230 A0 : 0x800d68e4 A1 : 0x3ffb1f90
A2 : 0x00000000 A3 : 0xfbb7cffd A4 : 0x3ffc1080 A5 : 0x3ffc1e08
A6 : 0x3ffc1958 A7 : 0x3ffc10e0 A8 : 0x800d182b A9 : 0x3ffb1f70
A10 : 0x0000007d A11 : 0xfbb7cffd A12 : 0x3ffc1e08 A13 : 0x00000005
A14 : 0x3ffc152c A15 : 0x3ffc1e08 SAR : 0x0000000a EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff
Backtrace: 0x400d182b:0x3ffb1f90 0x400d68e1:0x3ffb1fb0 0x40088b7d:0x3ffb1fd0
hmmm :S
Core 1 Panic'ed xD
Wish I had a regular M0 or M4 @obtuse spruce ... I know it adds a bt of compexity using one with WiFi
GOT IT
No, the WiFi isn't an issue
OKAY
So - how have you wired the break out to the board? I'm assuming that SCL and SDA are going to SCL and SDA as marked on the feather, right?
yep
and where did you wire the GPO pin on the breakout?
Haven't yet.. Got confused by the naming PB11 etc
gotcha - well, it is just a logic pin that tells you that some device RF'd with the breakout.... so if you sketch doesn't need it - don't wire it. If you do want then, just pick and unused pin that is both digital and interrupt capable.... which is almost all of them!
How about 5 - that's not used for anything
cool. okay and the LPD pin? I think that was the name
Yeah, LPD has some assignment ... And cool for pin #5 for GPO
I don't see LPD being used AT ALL in the ST25DV library - other than to provide simple functions that are just calls to digitalWrite and digitalRead
It is totally pointless..... So, whoop it up, define it as, er, 0
or better yet, 99 or something absurd
@quartz furnace - and I just searched through the library .... turns out it doesn't use the GPO pin either!!! so, no point in wiring it ... but you can if you intend to build your own things
Cool.. @obtuse spruce I did not know you could use a pin number not on the board
well - I'm sure the code will do something HORRIBLE if you ever execute code that uses such a pin.
@obtuse spruce ahhh cool.. Wish they would have left more in the 'notes' part of the code
But - the point is, it isn't going ever get called!
Unless you or some example sketch calls a function called ST25DV_GPO_* or ST25DV_LPD_*
and really - there is no point in calling those - just use pinMode and digitalRead and digitalWrite yourself - will make things clearer anyway!
@obtuse spruce interesting .. must just need defined to compile
ok there we go! it's no longer crashing now i just need to find out what is causing the crash
what i did was this
void loop() {
//FastLEDMatrix->UPDATE();
MySocket->loop();
}
so something inside the FastLEDMatrix class is causing the crash but i dunno what
@quartz furnace - yeah, you need to define them to something - any int at all - because the begin call needs them - but all the library does with them is save those two integers away, in case anyone calls those utility functions --- which nothing in the library or example sketches every does!
Basically they've got old legacy code in there and they need to clean it or document that it is there for older sketches (I'm guessing)
@obtuse spruce Thanks!
@elder hare Your code is trying to read from an illegal address in memory.
There does seem to be an unnecessary pointer in the class for some reason
Hi all. I wondering if anyone has ssl (client) working on ethernet ( not wifi ), on a adafruit feather. I'm using the m4 express, I tried modifying the ArduinoBearSLL WIFIsslClient example, which led to trying to get the ECCX08 random number generator example working ( the library is needed for BearSSL ), which led to maybe I need to define the wire that the crypto chip on the M4 uses, and then I got lost in the rabbit hole. Docs say the feather has a crypto chip on it, but no more details. I just want to connect to https. 😕
@lone ferry hmmm :S
@elder hare If you comment out the for loop in drawAnimation, and just do drawBitmap(bitmaps[0]); it will probably no longer crash.
@lone ferry check this out xD https://pastebin.com/TW3Mjfnv i've commented out almost everything... and it still crashes
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
But it does draw something?
I don't know if I have all your code but it does seem like you never actually create the FastLEDMatrix instance anywhere.
no now it does not draw anything as i have commented out this part in UPDATE()
// Check Strip Array Current Pattern and switch accordingly
/* switch (1){
case 1: drawAnimation(GalagaBoss, GalagaBossSize); break;
case 2: break;
case 3: break;
case 4: break;
default: break;
}*/
But before you commented that out, it did draw something?
weirdly yes :S the moment it starts up it starts crashing but it displays an image on the matrix
Where is the line in your code that does FastLEDMatrix = new MyFastLEDMatrix();?
all i have is this at the bottom of the pastebin i linked you
MyFastLEDMatrix *FastLEDMatrix;
Well, add the line FastLEDMatrix = new MyFastLEDMatrix(); to setup(), above the call to FastLEDMatrix->SETUP();
'FastLEDMatrix' was not declared in this scope
That makes no sense. Maybe you should put the latest versions of all your code files somewhere.
huh?
I can't really give you good advice if I don't know exactly what your code looks like.
@lone ferry https://github.com/MythicalForce/Prosjekt1 can you see this git?
yup
The problem is that you call FastLEDMatrix->UPDATE() but the variable FastLEDMatrix has some random value in it.
So you need to write FastLEDMatrix = new MyFastLEDMatrix(); first, in your setup().
aaaand that fixed it :S
weird that it worke this time :S
i feel the error stuff in Visual Studio is weird :S
Well, you need to do everything exactly right in C++ or it won't work. 😉
okey now that it does not crash! the image is still not animating
But it does show an image, right?
yupp 🙂
You need to put some kind of delay in the for-loop that does the animation or it will go way too fast.
hmm still nothing :S
How big is your delay?
500
Where did you put it?
void drawAnimation(const unsigned long** bitmaps, int s) {
for (int i = 0; i < s; i++) {
drawBitmap(bitmaps[i]);
delay(500);
}
}
I guess you need to put a FastLED.show(); right after that delay.
Anyway, GTG. Good luck 🙂
okey it worked now
but sad that i have to use delay() :S
@north stream why MUST i have delay? why can't i use the millis? :S
You can use millis unless something is interfering with the timer/interrupt
it should work as this
#ifndef MYFASTLEDMATRIX_H
#define MYFASTLEDMATRIX_H
#define FASTLED_INTERNAL
#include <FastLED.h>
#include <pgmspace.h>
#include "bitmaps/digdug.h"
#include "bitmaps/frogger.h"
#include "bitmaps/galaga.h"
#include "bitmaps/pacman.h"
#include "bitmaps/smb.h"
#include "bitmaps/qbert.h"
#define LED_TYPE WS2812B
#define DATA_PIN 23
#define COLOR_ORDER GRB
#define NUM_LEDS 256
#define COLS 16
#define BRIGHTNESS 16
CRGB leds[NUM_LEDS];
//====================================================================================================================== //
// CLASS - MY FASTLED MATRIX
//====================================================================================================================== //
class MyFastLEDMatrix {
public:
unsigned long lastUpdate = 0;
int Delay = 255;
void drawBitmap(const unsigned long* bitmap) {
FastLED.clear();
bool LTR = true; // Flips the image
for (int i = 0; i < NUM_LEDS; i += COLS) {
for (int j = 0; j < COLS; j++) {
int k = LTR ? j : COLS - 1 - j;
leds[i + k] = pgm_read_dword(&(bitmap[i + j]));
}
LTR = !LTR;
}
}
void drawAnimation(const unsigned long** bitmaps, int s) {
for (int i = 0; i < s; i++) {
drawBitmap(bitmaps[i]);
FastLED.show();
}
}
void UPDATE() {
unsigned long curtime = millis();
if (curtime > lastUpdate) { lastUpdate = curtime + Delay;
switch (1){
case 1: drawAnimation(SMBMario, SMBMarioSize); break;
case 2: break;
case 3: break;
case 4: break;
default: break;
}
FastLED.show();
}
}
};
MyFastLEDMatrix *FastLEDMatrix;
#endif
@north stream right?
As both matthijs and I pointed out, that declaration isn't correct.
what declaration?
MyFastLEDMatrix *FastLEDMatrix;
i have this in setup aswell
FastLEDMatrix = new MyFastLEDMatrix();
Then you can delete the other one.
You'll still need a declaration somewhere, I suppose.
yea cause if i delete the other i get
identifier "FastLEDMatrix" is undefined
how what when?
So - a common way to deal with singleton classes is just statically declare one. So long as you don't use anything "complex" in the constructor, you're fine, and in generally it makes things much easier.
In this case, just do this in the header file:
Class MyFastLEDMatrix {
...
};
and in the .ino file, the one place where it is used, do this:
MyFastLEDMatrix theMatrix;
...
void loop() {
...
theMatrix.UPDATE();
}
If you want to use theMatrix from multiple different code files... that is possible also:
In the .h file do this:
...
extern MyFastLEDMatrix theMatrix;
Then create a MyFastLEDMatrix.cpp file that has:
#include "MyFastLEDMatrix.h"
MyFastLEDMatrix theMatrix;
And lastly, in each file that needs to use theMatrix:
#include "MyFastLEDMatrix.h"
...
void someFunction() {
...
theMatrix.SomeFunction();
...
}
Hi all, I'm looking for help implementing the Arduino BLE library to create a peripheral device that multiple centrals can read from. I've covered my bike in NeoPixels with Arduino Nano 33 IOTs in each of the wheels, and a third Nano 33 IOT on the bike frame switching between animation modes with a NumberPad controller. I thought I would be able to make the nano on a Peripheral and "serve" the mode to the other two nanos in the wheels.
My questions are:
- Is this possible?
- Is there a better way using different hardware?
- Do you know of an example of how to set this up?
Any thoughts would be appreciated! Thank you! My code and project info is here: https://technochic.net/blogs/technochic-diy-projects/neopixel-bike-lights
I don't know any particulars about doing BLE on an Arduino, but in the face of it, it seems unlikely that a single device can server multiple centrals easily. Why not do it the other way around, having the spokes be the peripherals to the frame as central?
Thanks! I did try the other way around, and I've been able to send the "mode" from the central to the peripheral, but I don't know how to connect a second peripheral at the same time. 🤔
So the root of my question is: Does anyone know how (or know of an example or project) to use BLE to share a piece of data wirelessly between 3 Arduino's?
I’ve only ever seen Lora used for that tbh, I can’t say I have experience with ble hardware like that. That said, how much latency can you put up with?
Might it be possible to switch between modes to keep them all communicating with each other
For now, I'd take a few seconds lag if I could get it to work. 🙂
Aight
If it’s possible to get the devices to flipflop between central and peripheral modes I would consider that as a workaround unless you’re trying to do like, synced animations
That's interesting. Like daisy chaining the communication rather than broadcasting.
Honestly, I started the project wanting to learn more about BLE- but now I'm SO OVER that- haha. I didn't think of Wifi - I assume they can create their own network?
Can anyone help me out with my esp8266-01? I am trying to control a LED through adafruit IO. I am using the adafruit digital_out example code and the device is connected and receiving data, but the LED is not responding.
15:48:30.748 -> Adafruit IO connected. 15:48:30.889 -> received <- LOW 15:48:32.505 -> received <- HIGH 15:48:34.454 -> received <- LOW 15:57:55.157 -> received <- HIGH 15:57:58.310 -> received <- LOW
I have pin 3 (GPIO 0) active in the code and the LED is connected to pin 3
They use a different chipset than I’m used to so they might not offer the ability to create an AP, but if they can you could do it that way, or potentially set up a WiFi direct / ad hoc group
That said, the webpage says they can be both ble host and client, so hmmmmmm
Right that's why I was excited about the nano IOT - I had originally wanted to go with Adafruit Feathers but they didn't have the ability to be a "Peripheral / Server" and I didn't want to have to use my phone as a controller. It's an interesting thought tho - to create a wifi network between them instead. I'll look into that and maybe I'll leave my learning about BLE to another project. 🙂
Aye, wish I could be of more assistance, I’ve mostly stuck to the wired things :)
Thanks for your help! Me too... wires are so ... trustworthy. 😎
They just don’t do well when you wrap them around bike wheels and go for a ride, that’s for sure!
Haha no...
Oh wait
You don’t have three 33s?
You have a 33 and two feathers?
Your 33 needs to be set up as the peripheral
The feather wings will be the centrals
Right now all 3 are Arduino Nano 33 IOTs
https://www.arduino.cc/en/Reference/ArduinoBLE this should help ya out
Open-source electronic prototyping platform enabling users to create interactive electronic objects.
Ah, ok
Yeah I
I glanced at the project link you posted and it said you had the feather wings in the wheels
ve been reading that document over and over for weeks haha
Oh! That was the original plan. And then I started to learn 2 different BLE libraries and my brain started to explode :p
But switching to the Nanos didn't make it much better haha
There’s a lot of links on the right side of that page for how to use the code, with lots of examples; the document gives an overview of how things work and the code should help clarify?
Right, unfortunately, I'm learning as I go, and the examples say what to do but not why and when, so I've struggled with it. My best try code is listed at the bottom of my blog post (although it's a bit long because it includes the neopixel animations too)
Fair enough!
This looks like it has lots of good example code as well
If I had the ble version of the iot nano I would do some testing for you but I have the Lora versions >_>
I dont' know Lora - should I look into it for this project?
Here is the reference for the WiFi library in case it looks like it may be easier for you https://www.arduino.cc/en/Reference/WiFiNINA
Open-source electronic prototyping platform enabling users to create interactive electronic objects.
Your current devices should work alright, to be honest
Lora is for long range / low [data] rate, so trying to stream audio reactive animations in real-time over Lora is gonna give you more headaches than doing it with ble
Gotcha. Yes I just need to send data a few feet. Thanks for the help 🙂
I might split the difference and use ordinary RFM69 type radios and the RadioHead library (BLE has its own headaches)
Or for just a few feet, your original WiFi idea might be the right one
Ah... I was just reading about that yesterday. Something seemed out of date tho - was it discontinued?
The RFM69 chips or the library?
The library
https://forum.arduino.cc/index.php?topic=674281.0 here is a thread where someone explained how to have multiple clients connecting btw, might be useful
Fast transmission of data via BLE to multiple cilents
Oh wow that looks very helpful. Thank you!
Even if Mike McCauley's original RadioHead library isn't maintained (I hadn't heard anything), Paul Stroffregen (of PJRC/Teensy fame) has a fork of it, and SparkFun has their own fork as well.
It's a pretty solid and expansive library, even if no one else were maintaining it, I'd probably keep using it, as it serves my purposes nicely.
Ok thanks! I'll look into it. At this point any radio communication to the wheels that works will be AMAZING. Thank you!
still no luck @stone dirge ?
afternoon! I was wondering if its possible to count the number of Bluetooth devices I have passed using a GEMMA M0 and log it to a string
I know my question is broad but I'm hoping to be point in the right direction with this idea 🙂
It is if you have a bluetooth chipset that can return advertisments which is basically all of them
but remember peoples MACs change constantly, so its not terribly great for tracking if that was a goal
the basic idea is if I go into town for the day, I wanted to get a rough number of people I passed
Don't need to be able to track the devices again in the future
You could probably graph a rough relative measurement, youll stumble on many many devices around you that have bluetooth but are not a cell phone
is there anyway to filter them out?
Its possible phones typically have a part of their advertisment different, Im not too sure if they set their advertising payload for some extra function you could base the scanner off of
I think itll probably just be a list of random MACs is all you get
I see
well that is a start
any good resources on writing code to do this kind of thing?
Most of the time its specific to the BT chipset, make sure you dont get one of those popular BT Serial modules. Not really sure of a solid recommendation for an external chipset that is good with arduino
I have a bluno beetle, what about that?
Hm maybe, it uses serial like the modules but now that I think of it a part of BLE 4.0 GATT should be its required to return you the advertisment data so you'd have to check the AT commands for that device
@stuck coral thanks for the info, does adafruit have a board that would be best for this?
I like using Adafruit stuff as it has very good documentation
I love the nRF52 and they have a few boards if I remember right
That will certainly do the job, I just havnt used the Arduino framework with it
those are big though right?
I mean, I think they have a feather with a nRF52 on it, but the nRF52 itself can be quite tiny
thanks, I'll check it out
@stuck coral What is wrong with BT Serial modules like the HC-05 and HC-06
you said not to use them
@stuck coral Do all smartphones send out advertisements? as long as bluetooth is on?
They tend to be limited from what I see, but they might have an AT command to get the advertising data.
And yeah, pretty sure they always send advertisments but I could be mistaken, i see when my neighbors get home if I have my scanner open
Thanks! I would really appreciate that. 😄
hey im completely lost when it comes to batteries. If I wanted to power an arduino nano and a 12v water pump with a battery, what battery should I go with for it to last a while. I was thinking something like this https://www.banggood.com/12V-8-x-AA-Battery-Clip-Slot-Holder-Stack-Box-Case-6-Inch-Leads-Wire-p-80721.html?cur_warehouse=CN&rmmds=search and then using a 12v to 5v step down to power the arduino. I have no idea if this would work cuz I have never used batteries before. Any help would be greatly appreciated.
Online Shopping at Banggood.com!
Pumps draw a lot of power, define “last awhile”
I want it to last a few days, but I am only turning on the pump for less than 2 seconds at a time every so often
its more of a mist sprayer than a continuous water pump
On for a second and off for a second? Off for an hour?
You might be better off buying some actual 6v or 12v batteries
Instead of AAs
it would be on for a second then off for something like an hour. I would prefer for the batteries to be replicable in something like this battery pack if possible
or i guess rechargeable would work too
would something like this work better?
I would certainly use 8 cell NiMH rechargeable or 3cell LiPo (nominal voltage 11.1v) instead of AA.
And you do not need a voltage converter - nano has one on board. Typically you can power nano using up to 20 v
oh great
i guess ill go with the 8 cell nimh and see how it goes
thanks for all the help 🙂
Of course there are many different nano boards - double-check the specs for yours
yea i will for sure
Is there a way i can multiply two integers as if they were floats in the range 0-1. For example 65535 * 32767 = 32767
platform is teensy 4
Yes, but you need to do this in 32-bit and divide by 65535 afterwards. (Or rather, shift right by 16.)
@obtuse spruce i just did what you told me yesterday
im still getting weird errors :S
even tho i have this function
void drawAnimation(const unsigned long** bitmaps, int s) {
for (int i = 0; i < s; i++) {
drawBitmap(bitmaps[i]);
FastLED.show();
}
}
inside the main UPDATE() function that runs in the main loop
void UPDATE() {
unsigned long curtime = millis();
if (curtime > lastUpdate) { lastUpdate = curtime + Delay;
switch (1){
case 1: drawAnimation(SMBMario, SMBMarioSize); break;
case 2: break;
case 3: break;
case 4: break;
default: break;
}
FastLED.show();
}
}
as with the original code you had to have a delay() inside the drawAnimation for loop to make it animate to make it work if not it would just stand still so i figure the problem is in
void drawAnimation(const unsigned long** bitmaps, int s) {
for (int i = 0; i < s; i++) {
drawBitmap(bitmaps[i]);
FastLED.show();
}
}
in the for loop! even tho i have the millis in place the for loop just rams through the "animation" so fast that you dont see it
am i wrong?
What is wrong is that your drawAnimation tries to run the entire animation, but it should only show the next frame of the animation. The next time it is called, it should show the frame after that, and so on.
question, how would i solve this? WITHOUT using delay()! need millis
drawAnimation(SMBMario, SMBMarioSize, step); where step is a global variable that you update.
void drawAnimation(const unsigned long** bitmaps, int size) {
drawBitmap(bitmaps[step]);
step += 1;
if (step >= size) { step = 0; }
}
Actually I didn't use step as a parameter there, it should be a global.
Put int step = 0; somewhere outside your functions.
i did hmm
on this
drawAnimation(SMBMario, SMBMarioSize, step);
i get
too many arguments in function call
Yeah I changed my mind about that one, you don't need it.
I have a c++ uint8_t *payload
that I am trying to iterate thru by using a
char license[20];
for (size_t i = 1; i < (sizeof(payload) + 1); i++)
{
Serial_Debug.println((char)payload[i]);
license[i] = (char)payload[i];
}
Serial_Debug.println(license);
but no matter how long the array is it always comes back as 4...
the Payload in this instance is "SWDFE"
In the Serial Monitor it receives the data but I cant get past a count of 4
@SWDFE
S
W
D
F
#SWDF␌␆
You can't use sizeof() to get the size of an array like that.
You can't use
sizeof()to get the size of an array like that.
@lone ferry It always comes back as 4
C arrays don't actually store their size anywhere.
What you're getting here is the size of the pointer, which is 4 bytes.
You can usefully call sizeof() on a fixed array, but not a pointer like that.