/r/arduino

Photograph via snooOG

An unofficial place for all things Arduino!

We all learned this stuff from some kind stranger on the internet. Bring us your Arduino questions or help answer something you might know! 😉

/r/arduino

646,188 Subscribers

1

Complete beginner to arduino here

I'm planning to make an arduino-based automatic watering system. Would it be possible to connect 3 soil moisture sensors and solenoid valves to a single arduino uno r3?

0 Comments
2024/05/02
13:41 UTC

1

can I use an 8GB SD card with MP3-TF-16P v3.0?

I have an MP3_TF 16P V3.0 module and I want to connect it with Arduino to store some sound file

actually, it is the first time for me to use one of these modules

I saw some videos on YouTube and some people say if you want to store some sound files you mustuse a 32GB SD card and others say it is ok if you use an 8,16 or 32GB SD card

my question is what space should I buy?

thanks for any kind of help

0 Comments
2024/05/02
13:34 UTC

1

What micro-controller to buy?

Hi! I'm now planning what I'll need for my first project. I want to make an alarm clock that plays megalovania and later I want to extend its functionality to also pull the curtain up using a pulley. Anyway what board do you think will be best suited for this and also where can i find information like this for future projects?

2 Comments
2024/05/02
13:22 UTC

1

why my school prject dont work

Hello, I'm new to using Arduino. I was making a robot that avoids obstacles. Even though I wrote the code correctly for the motor driver, the motors weren't working. I bought a new motor driver, but the same problem persists. Arduino isn't faulty (I tested it with the blink code). What should I do?

#define echoPin 12 //Ultrasonik sensörün echo pini Arduino'nun 12.pinine
#define trigPin 13 //Ultrasonik sensörün trig pini Arduino'nun 13.pinine tanımlandı.
#define MotorR1 7
#define MotorR2 6
#define MotorRE 9  // Motor pinlerini tanımlıyoruz.
#define MotorL1 5
#define MotorL2 4
#define MotorLE 3
long sure, uzaklik; //süre ve uzaklık diye iki değişken tanımlıyoruz.
void setup() {
  // ultrasonik sensör Trig pininden ses dalgaları gönderdiği için OUTPUT (Çıkış),
  // bu dalgaları Echo pini ile geri aldığı için INPUT (Giriş) olarak tanımlanır.
  pinMode(echoPin, INPUT);
  pinMode(trigPin, OUTPUT);
  pinMode(MotorL1, OUTPUT);
  pinMode(MotorL2, OUTPUT);
  pinMode(MotorLE, OUTPUT); //Motorlarımızı çıkış olarak tanımlıyoruz.
  pinMode(MotorR1, OUTPUT);
  pinMode(MotorR2, OUTPUT);
  pinMode(MotorRE, OUTPUT);
  Serial.begin(9600);
}
void loop() {
  digitalWrite(trigPin, LOW); //sensör pasif hale getirildi
  delayMicroseconds(5);
  digitalWrite(trigPin, HIGH); //Sensore ses dalgasının üretmesi için emir verildi
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW); //Yeni dalgaların üretilmemesi için trig pini LOW konumuna getirildi
  sure = pulseIn(echoPin, HIGH); //ses dalgasının geri dönmesi için geçen sure ölçülüyor
  uzaklik = sure / 29.1 / 2; //ölçülen süre uzaklığa çevriliyor
  Serial.println(uzaklik);
  if (uzaklik < 15) // Uzaklık 15'den küçük ise,
  {
    geri();  // 150 ms geri git
    delay(150);
    sag();  // 250 ms sağa dön
    delay(250);
  }
  else {  // değil ise,
    ileri(); // ileri git
  }
}
void ileri(){  // Robotun ileri yönde hareketi için fonksiyon tanımlıyoruz.
  digitalWrite(MotorR1, HIGH); // Sağ motorun ileri hareketi aktif
  digitalWrite(MotorR2, LOW); // Sağ motorun geri hareketi pasif
  analogWrite(MotorRE, 150); // Sağ motorun hızı 150
  digitalWrite(MotorL1, HIGH); // Sol motorun ileri hareketi aktif
  digitalWrite(MotorL2, LOW); // Sol motorun geri hareketi pasif
  analogWrite(MotorLE, 150); // Sol motorun hızı 150
  
  
}
void sag(){ // Robotun sağa dönme hareketi için fonksiyon tanımlıyoruz.
  digitalWrite(MotorR1, HIGH); // Sağ motorun ileri hareketi aktif
  digitalWrite(MotorR2, LOW); // Sağ motorun geri hareketi pasif
  analogWrite(MotorRE, 0); // Sağ motorun hızı 0 (Motor duruyor)
  digitalWrite(MotorL1, HIGH); // Sol motorun ileri hareketi aktif
  digitalWrite(MotorL2, LOW); // Sol motorun geri hareketi pasif
  analogWrite(MotorLE, 150); // Sol motorun hızı 150
  
  
}
void geri(){ // Robotun geri yönde hareketi için fonksiyon tanımlıyoruz.
  digitalWrite(MotorR1, LOW); // Sağ motorun ileri hareketi pasif
  digitalWrite(MotorR2, HIGH); // Sağ motorun geri hareketi aktif
  analogWrite(MotorRE, 150); // Sağ motorun hızı 150
  digitalWrite(MotorL1, LOW); // Sol motorun ileri hareketi pasif
  digitalWrite(MotorL2, HIGH); // Sol motorun geri hareketi aktif
  analogWrite(MotorLE, 150); // Sol motorun hızı 150
  
}


https://preview.redd.it/dwy58z7ih0yc1.png?width=1826&format=png&auto=webp&s=4f9d9c1887e725072e02199072b0de0e3b5c1a92

7 Comments
2024/05/02
13:02 UTC

2

Calculated ampere needs make me unsure about power supply needed

I want to power a 300 LED / 5M RGB LED Strip, a small Arduino and some rotarys etc. Nothing fancy.

After I started looking for a power supply I got a bit confused.

The LEDs need around 0.3W at full brightness (BTF Lighting WS2812), Arduino needs a bit and maybe some added small peripherals im not sure about yet.

The LED Strip alone needs 18A it seems if I don't miss something very obvious.

So I guess I have to go for a 5V 20A power supply?
My gut feeling says overkill, just a dammn LED strip not a flood light.

6 Comments
2024/05/02
12:42 UTC

1

HX711 and load cell wiring lenght, which is better?

I have a project with two load cells at opposite sides with my Arduino at the middle section. From what I read theses Hx711 are sensitive to interference and noise.

I can have the HX711 boards near the load cells, A, or near the Arduino B.

Which one would be better for less problems with noise please?

Near load cell or near Arduino???

Thanks!

5 Comments
2024/05/02
10:54 UTC

1

Problem with connecting to page

Hi , im trying to create html web page with showing some temperatures ..... I have one problem , the web page opens only one time . When i close the web browser and try to open the page on other computer i have error (cant reach). The program is :

#include <DHT.h>                      // Kniznica pre DHT snimac
#include <Ethernet.h>                 // Kniznica pre ethernet
#include <EthernetClient.h>
#include "stranka.h"                  // Subor pre webstranku

IPAddress ip(192, 168, 20, 144);      // IP Adresa Arduina
IPAddress mask(255, 255, 255, 0);     // Maska pre server
IPAddress gateway(192, 168, 20, 1);   // DNS pre server
EthernetServer server(80);            // Port servera

// Nastavenie senzorov
#define DHTPIN1 7         // Senzor vonkajsia teplota
#define DHTPIN2 8         // Senzor vnutorna teplota
#define DHTPIN3 9         // Senzor teplota potrubia 

#define DHTTYPE1 DHT21 
#define DHTTYPE2 DHT21  
#define DHTTYPE3 DHT21 
DHT dht1(DHTPIN1, DHTTYPE1); 
DHT dht2(DHTPIN2, DHTTYPE2); 
DHT dht3(DHTPIN3, DHTTYPE3); 

//Nastavenie vstupov 
int Netatmo_w = 0;      //Vstup z netatma
int Thermostat_w = 1;   //Vstup z termostatu
int PWM_vst = 2;        //PWM_VstupnaMriezka 
int PWM_rek = 3;        //PWM_RekuperacnaMriezka
int oh1 = 4;            //Ohrev1
int oh2 = 5;            //Ohrev2
int oh3 = 6;            //Ohrev3

void setup() {
  Serial.begin(9600);
  Ethernet.begin(ip, mask, gateway);
  server.begin();
  dht1.begin();
  dht2.begin();
  dht3.begin();

  pinMode(0, INPUT);     //Netatmo
  pinMode(1, INPUT);     //Termostat
  pinMode(2, OUTPUT);    //PWM_VstupnaMriezka
  pinMode(3, OUTPUT);    //PWM_RekuperacnaMriezka
  pinMode(4, OUTPUT);    //Ohrev1
  pinMode(5, OUTPUT);    //Ohrev2
  pinMode(6, OUTPUT);    //Ohrev3
  pinMode(PD_5, OUTPUT); //Ledka na doske pre zobrazenie spojenia
}

void loop() {


// Deklaracia premmenych , nacitanie vstupov , nacitanie snimacov a ukladanie do patame 
  int hum1 = dht1.readHumidity();
  int temp1 = dht1.readTemperature();
  int hum2 = dht2.readHumidity();
  int temp2= dht2.readTemperature();
  int hum3 = dht3.readHumidity();
  int temp3= dht3.readTemperature(); 
  int Netatmo = digitalRead(Netatmo_w);
  int Thermostat = digitalRead(Thermostat_w);
  bool term, netat, ohrev1, ohrev2, ohrev3;
  int pwm_vst_w , pwm_rek_w; 
  int temp_z, temp1_z, temp2_z ;

// Citanie vstupu pre Thermostat a Netatmo
    if(Thermostat == HIGH)
    term = true;
    else
    term = false;

    if(Netatmo == HIGH)
    netat = true;
    else
    netat = false;

// Porovnavanie vstupov netatma a termostatu pre zapnutie ohrevu      
   if((Netatmo == HIGH) && (Thermostat == HIGH)){
      digitalWrite(oh1, HIGH);
      delay(5000);
      ohrev1 = true;
      digitalWrite(oh2, HIGH);
      delay(5000);
      ohrev2 = true;
      digitalWrite(oh3, HIGH);
      delay(5000);
      ohrev3 = true;}
    else{
      ohrev1 = false;
      ohrev2 = false;
      ohrev3 = false;
      digitalWrite(oh1, LOW);
      digitalWrite(oh2, LOW);
      digitalWrite(oh3, LOW);}

// Riesenie PWM na otvaranie zaluzii (vonkajsej a rekuperacnej)
/*  if(temp > 20 ){
      analogWrite(PWM_vst, 255);
      analogWrite(PWM_rek, 0);
      pwm_vst_w = 100;
      pwm_rek_w = 0;}
          else if((20 > temp) && (temp > 15)){
                analogWrite(PWM_vst, 204);
                analogWrite(PWM_rek, 51);
                pwm_vst_w = 80;
                pwm_rek_w = 20;}
                else if((15 > temp) && (temp > 10)){
                      analogWrite(PWM_vst, 127);
                      analogWrite(PWM_rek, 127);
                      pwm_vst_w = 50;
                      pwm_rek_w = 50;}
                      else if((10 > temp) && (temp > 5)){
                            analogWrite(PWM_vst, 51);
                            analogWrite(PWM_rek, 204);
                            pwm_vst_w = 20;
                            pwm_rek_w = 80;}
                            else if(5 > temp){
                                  analogWrite(PWM_vst, 0);
                                  analogWrite(PWM_rek, 255);
                                  pwm_vst_w = 0;
                                  pwm_rek_w = 100;} 
*/
pwm_vst_w = 69; 
EthernetClient client = server.available();
  if (client) {
    Serial.println("Nove kolo");
    
    // Odeslání hlavičky HTTP
    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println();
    digitalWrite(PD_5, HIGH);
//    delay(5000);
    
    // Odeslání obsahu HTML stránky
    client.println(PAGE_MAIN);
    Serial.println("Stranka sa zobrazila idem dalej");
    client.flush();
    Serial.println("Splachol som");
    client.stop();
    digitalWrite(PD_5, LOW);
    Serial.println("Ledka Zhasla");}

}

The program broke in client.stop(); the last output is Serial.println("Splachol som"); . thats all , i cant connect to the this ip ( only one time )

0 Comments
2024/05/02
09:13 UTC

1

Wifi Connection Issues for WebServer codes

I’m using an Arduino Nano ESP32 and an MLX90640 to receive temperature data in a heat map, sent to a webserver. I am using a github code.

At home, the code runs completely fine, but the moment I try to run the code in my university, it doesn’t connect to the WiFi at all, whether it’s my hotspot or eduroam. The university wifi also has a log in thing where you need your id and password to log in, so no set wifi password.

Does anyone have any advice on how to connect the nano to a WPA2 Enterprise WiFi network? Or even to my phone’s hotspot? I don’t know exactly why it isn’t working.

Here is the github link I used:

https://github.com/Samox1/ESP_Thermal_Camera_WebServer

I tweaked it based on my specifications, but it’s mostly the same.

Any advice is appreciated!

0 Comments
2024/05/02
09:11 UTC

2

Arduino/Raspberry Pi project help

I am starting to build a proposal for my final year Mechanical Engineering dissertation project at university. My idea is to build a simulated automated production line using a raspberry Pi/ Tiny ML kit to control it and perform quality sorting checks to automatically remove failed items from the line. I have done some research and found edge impulse to train the image model.

The mechanical side of things will not be an issue for me as I can build a rig to simulate the production line and I have experience using Arduinos to count, control servos etc.

I am a bit dubious on how to approach setting the project up.

I have experience with using arduinos but nothing with raspberry Pi (which I have seen quoted that it will be necessary to run using both). Also, will a tiny ml kit be suitable for the application I am aiming to simulate or will I have to look at something more advanced?

Can anyone point me in the right direction? I could use the critical advice!

3 Comments
2024/05/02
07:29 UTC

2

Problems with the conversion of a weird Datatyp

I am programming a BMP280

The code i got for it gets me the pressure in Arduino::String

And i just can't change it into any other datatyp, i tried multiple ways to convert it but it always fails, it just says that i can't convert this datatyp into another one

I need to have it in double, in order to use it in some calculations and other Functions

Help would be appreciated

1 Comment
2024/05/02
06:29 UTC

2

Arduino Project Idea

How would i build a project that picks up radio frequencies and marks them geographically?

1 Comment
2024/05/02
05:57 UTC

9

In modifying the circuitry of this children's audio toy I created a probability based sequencer using an Arduino to sequence the hi-hat sound. The knob on the far left controls the tempo, the middle knob controls the swing, and the last knob controls the probability the hat will trigger.

3 Comments
2024/05/02
05:23 UTC

4

LCD 16x2 White Boxes (Issue)

Hi everyone, Im trying to familiarize myself with Arduino and just want to try to display "Hello World" on the LCD but I keep getting those white boxes on top. I've searched but couldn't find any worthwhile answers. Any help would be greatly appreciated and sorry for the messy wiring in the picture. Hope it's understandable enough.

*Note: The LCD screen isn't soldered into the Header pins yet, I read that it wouldn't affect it but im not sure.

The code:

include <LiquidCrystal.h> // Define the pins used for the LCD const int rs = 12; // RS pin of LCD connected to digital pin 12 const int en = 11; // Enable pin of LCD connected to digital pin 11 const int d4 = 5; // D4 pin of LCD connected to digital pin 5 const int d5 = 4; // D5 pin of LCD connected to digital pin 4 const int d6 = 3; // D6 pin of LCD connected to digital pin 3 const int d7 = 2; // D7 pin of LCD connected to digital pin 2

// Define the dimensions of the LCD (columns x rows) const int lcdColumns = 16; const int lcdRows = 2;

// Create an instance of the LiquidCrystal library LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() { // Set up the LCD's number of columns and rows lcd.begin(lcdColumns, lcdRows);

// Display "Hello, World!" on the LCD lcd.clear(); // Clear the LCD screen lcd.setCursor(0, 0); // Set cursor to first column, first row lcd.print("Hello, World!"); }

void loop() { // Leave loop empty as we only want to display the text once }

4 Comments
2024/05/02
04:20 UTC

3

Error uploading on a nano

I'm new in arduino programming, I'm trying to make a solar tracker for school and thus figuring out how does it work, so now I just tried to upload a bare minimum sketch from the examples but it gave me an error after waiting what I felt as a really long time for a blank program, I've also noticed the built in led is blinking and tried to over write it with another blinking led from the example sketches but it gave me the same errors, also tried to upload while holding the reset button but didn't work, I really do not understand what is going on, I could make my own code for the homework but the error is really weird.

This is the error:

El Sketch usa 444 bytes (1%) del espacio de almacenamiento de programa. El máximo es 30720 bytes.
Las variables Globales usan 9 bytes (0%) de la memoria dinámica, dejando 2039 bytes para las variables locales. El máximo es 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xb9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xb9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xb9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xb9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xb9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xb9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xb9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xb9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xb9
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xb9
Failed uploading: uploading error: exit status 1

The code I'm uploading is literally just this:

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}
4 Comments
2024/05/02
04:03 UTC

2

LED strip brightness without any PWM.?

I’ve googled around but I’m not 100% sure what I’m looking for, but I want to control led strip brightness without any PWM. The circuit will be used in close proximity to circuitry sensitive to switching noise.

I believe I’m looking for a constant current source/sink circuit that I can somehow control without a bunch of high frequency switching involved. Digital POTs not off the table. Anyone point me to the right direction to get some traction on what I’m looking for? Thanks!

6 Comments
2024/05/02
03:27 UTC

5

I need help with my dile :(

I made a circuit with a temperature and humidity sensor (I attach tests with an image) but the Code shows me this error "fatal error: DHT.h: no such file or directory" I attach my Code below

#include <LiquidCrystal.h> int rs = 12; int e = 11; int d4 = 5; int d5 = 4;

int dTime = 500; //pantalla

int d6 = 3; int d7 = 2; int numero = 0;

LiquidCrystal lcd(rs, e, d4, d5, d6, d7);

//programacion del sensor aca abajo #include <DHT.h> #include <DHT_U.h>

#define Type DHT11 int dhtPin = 10; DHT HT (dhtPin, Type); int humidity; float tempC; float tempF;

void setup(){

lcd.begin(16, 2); Serial.begin(9600); HT.begin(); } void loop(){

humidity = HT.readHumidity(); tempC = HT.readTemperature(); //tempF = HT.readTemperature(true); Serial.print("Humedad Relativa: "); Serial.print(humidity); Serial.print("% / Temperatura: "); Serial.print(tempC); Serial.print("°C / "); Serial.print(tempF); Serial.println("°F");

lcd.setCursor(0, 0); lcd.print("Humedad: "); lcd.print(humidity); lcd.print("%");

lcd.setCursor(0, 1); lcd.print("Temp.: "); lcd.print(tempC); lcd.print("*C");

delay(dTime); lcd.clear(); }

4 Comments
2024/05/02
02:57 UTC

2

SevSegShift.h not working as intended due to Arduino limitations?

Hey everyone, I'm looking for help using the SevSegShift.h library. I have some weird behaviour going on that I can't really explain and was hoping if anyone could help (just FYI, I'm a complete novice).

I was working with a seven segment display, and trying to imploment a way where I can give it a letter and a number, and it will display the combination. For this purpose, I made a function that returns a string, which can then be used with the string.toCharArray() in combination with sevsegshift.setChars() to set the right characters.

However, the code doesnt seem to like me doing this. It compiles just fine, but whenever I do something that calls the string returning function, the sevseg display stops functioning (alongside a button library Im using). I have taken my original code (a rather large project) and distilled it down for troubleshooting. I hope someone can help me make sense WHY this is going wrong.

In the distilled troubleshooting code, I define the necesarry pins and set up my sevsegdisplay during setup. The following loop runs fine, and I see "123" displayed on the sevseg, just as expected.

void loop() {
  sevsegshift.setNumber(123);
  sevsegshift.refreshDisplay();
  // crashTest();
}

However, when I uncomment the crashTest and call its functions (see below), the sevseg display crashes as soon as the if condition is met.

void crashTest() {
  unsigned long currentSevSegTime = millis();
  const unsigned long delayDuration = 2000;
  static String stringholder;

  if (currentSevSegTime > delayDuration) {
    stringholder = getString("a", 123);
  }
}

String getString(String inputText, int number) {
  String space = " ";
  String buffer;
  if (number >= 100) {
    buffer = String(inputText + number);
  } else if (number >= 10) {
    buffer = String(inputText + space + number);
  } else if (number >= 0) {
    buffer = String(inputText + space + space + number);
  } else buffer = String(inputText + "---");
  return buffer;
}

I just find it so strange that eventhough the crashTest function is doing nothing to the sevseg display, it is still breaking somehow. Like I mentioned before, although it is not in this distilled troubleshooting version, when the "bug" occurs it also messes up timings of other libraries, like my button library. Can anyone help me brainstorm to think what might be wrong here?

10 Comments
2024/05/02
01:34 UTC

1

Beginner doubts

Hi! I´m starting my journey in arduino projects, so I´m learning simple projects.

Using the push button that i own on my arduino kit, it has 2 pines, I learned how to program to on/off a LED using a 4 pines push button.. How can I program the arduino to do on/off when I push the button instead of switching on only while I push it. In my way of thinking, I need a 4 pines button to do that, but I´m not understanding how can I use them.

I´m excited to my new journey, if u have good materials to complement my study, send me!

4 Comments
2024/05/02
00:37 UTC

3

Shutter Speed Tester [Help!]

Disclaimer: I'm a very analog-minded person and programming/coding is completely foreign and unintuitive to me. This project was appealing since it appeared as though I could assemble the circuit and upload the provided code and quickly get along to using the final product.

I repair mechanical film cameras and frequently have a need to test shutter speeds. I usually do this by testing with a roll of film to verify that everything works, but I'd like to be able to use an Arduino to measure the shutter speeds as well. I stumbled across this post on Hackaweek, which then led me to the originial source for the project on GitHub.

I ordered the parts I needed based on the schematic on GitHub. I assembled it, fiddled around quite aimlessly in Arduino IDE, but finally got the code flashed onto the SEEED Xiao-RP2040. When I power on the device, the LED display correctly displays the "Shutter Speed Tester" text, but upon attempting to flash a light into the photodiode (by quickly flicking a flashlight on/off), nothing happens..

I've quadruple-checked that I've assembled the circuit correctly. I've measured the voltage across the phototransistor when the tester is powered on and subject to "ambient" light, and the potential is just under 3.3V (which is the supplied power from pin 12 on the RP-2040). When I shine a bright flashlight into the phototransistor, the voltage drops dramatically to less than 0.5V.

All mechanical components appear to be working as they should, so I'm suspicious that the code is the reason something isn't working. I don't even know where to start, so I'm hoping someone will be able to guide me a bit. The photo I'm including is of my shutter tester powered on, with the display obviously functional.

Thanks!

https://preview.redd.it/gutnpxgniwxc1.jpg?width=3000&format=pjpg&auto=webp&s=1fd5dd9986d2b199d22f9fea38af6667fe3f76dc

1 Comment
2024/05/01
23:44 UTC

3

Anyone know what kind of motor I would need to get this door to open?

Okay so this being my first addition project. I’m trying to develop a system where I can connect the HM-10 module from my phone and open the door using a motor but I realize the SG-90 is a little too weak for this task. Any ideas on how I could calculate the torque/ what sort of motor I should be looking to use?

Also if the motor voltage is higher than 5, can I amplify the 5V output from the arduino or would I need to generate a completely different voltage source?

4 Comments
2024/05/01
23:22 UTC

3

Trying to rewire a Gyrotron Amusement Ride. However, the Arduino Due outputs on the DAC0 regardless of the inputs.

We have a Gyrotron that I am working on rewiring so I can get rid of the computer that was new in 1991. The Motor Driver triggers when it receives a voltage. I am sending the voltage from the DAC0 on a Arduino DUE. However, regardless of what happens, the DUE outputs on the DAC0. I'm using the Arduino IDE to load the program into the DUE, and it says it is loading ok. However, it doesn't seem to matter what I am doing with the inputs, the DAC0 seems to just keep outputting about 1.5 volts. What am I doing wrong? I assume its something with the DUE or loading the program, but I have the program below just in case.

Only things that aren't actually being used is the Hall Switch, which shouldn't matter, the boost input which shouldn't matter, and the outputs for the warning lights aren't actually hooked up.

  // Pin definitions
const int pinSlowSpeed = 2;
const int pinFastSpeed = 3;
const int pinSpeedBoost = 4;
const int pinStartButton = 5;
const int pinEmergencyStop = 6;
const int pinDurationSwitch = 7;
const int pinHallSwitch = 8;
const int pinSafetyCheck = 14;
const int pinWarningLight = 15;
const int pinHomeLight = 16;

// Speed Settings
int baseSpeedPercentage = 40; // Default to medium speed
int currentSpeedPercentage;
bool rideActive = false;
unsigned long rideStartTime;
unsigned long rideDuration = 45000; // Default to 45 seconds

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

  pinMode(pinSlowSpeed, INPUT_PULLUP);
  pinMode(pinFastSpeed, INPUT_PULLUP);
  pinMode(pinSpeedBoost, INPUT_PULLUP);
  pinMode(pinStartButton, INPUT_PULLUP);
  pinMode(pinEmergencyStop, INPUT_PULLUP);
  pinMode(pinDurationSwitch, INPUT_PULLUP);
  pinMode(pinHallSwitch, INPUT_PULLUP);
  pinMode(pinSafetyCheck, INPUT_PULLUP);
  pinMode(pinWarningLight, OUTPUT);
  pinMode(pinHomeLight, OUTPUT);
  
  analogWriteResolution(12);  // DAC0 on the Due has 12-bit resolution
  analogWrite(DAC0, 0);       // Ensure motor is off initially
}

void loop() {
  handleEmergencyStop();
  //Start the ride here.
  if (digitalRead(pinStartButton) == LOW) {
    if (digitalRead(pinSafetyCheck) == LOW) { //checks the safety interlocks
      if (digitalRead(pinEmergencyStop) == LOW) { //checks to be sure the Emergency stop is not pushed
        handleRideDurationSwitch();
        startRide();
        delay(1000); //this delay ensures that the start button is released in time and does not cause the ride to stop again.
      } else {
        Serial.println("Check Safeties");
        digitalWrite(pinWarningLight, HIGH);
        delay(500);
        digitalWrite(pinWarningLight, LOW);
        delay(500);
        digitalWrite(pinWarningLight, HIGH);
        delay(500);
        digitalWrite(pinWarningLight, LOW);
        delay(500);
        digitalWrite(pinWarningLight, HIGH);
        delay(500);
        digitalWrite(pinWarningLight, LOW);
      }
    }
  }
  // This triggers while the rideActive variable is on.
  if (rideActive) {
    //Checks if the speed selection has changed, and updates the DAC0 output to reflect it.
    handleSpeedControl();
    //Checks the remaining time, and stops the ride if the ride is finished.
    checkRideTimeout();
    //Checks if the rotations is going faster than 12 RPMs, and shuts down the ride if it happens.
    monitorSpeedSensor();
    //If you push the start button again, the ride will slow its speed and begin the homing function.
    if (digitalRead(pinStartButton) == LOW) {
      rideActive = false;
      Serial.println("Ride Stopped By Operator");
      findHomePosition();
    }
  }
}

void handleSpeedControl() {
  if (digitalRead(pinFastSpeed) == LOW) {
    baseSpeedPercentage = 50;
  } else if (digitalRead(pinSlowSpeed) == LOW) {
    baseSpeedPercentage = 30;
  } else {
    baseSpeedPercentage = 40;
  }

  currentSpeedPercentage = baseSpeedPercentage;
  if (digitalRead(pinSpeedBoost) == LOW) {
    currentSpeedPercentage = baseSpeedPercentage * 1.2;
  }

  analogWrite(DAC0, map(currentSpeedPercentage, 0, 100, 0, 4095));
  Serial.print("Current Speed: ");
  Serial.println(currentSpeedPercentage);
}

void handleEmergencyStop() {
  while (digitalRead(pinEmergencyStop) == HIGH) {  // Normally Closed Switch High Means it is triggered, Low Means it is not.
    Serial.println("Emergency Stop Activated!");
    analogWrite(DAC0, 0);
    digitalWrite(pinWarningLight, HIGH);
    rideActive = false;
  }
}

void monitorSpeedSensor() {
  static unsigned long lastTriggerTime = 0;
  if (digitalRead(pinHallSwitch) == LOW) {
    unsigned long currentTime = millis();
    if (currentTime - lastTriggerTime < 5000) {
      Serial.println("Speed anomaly detected!");
      digitalWrite(pinHomeLight, HIGH);
      rideActive = false;
      analogWrite(DAC0, map(10, 0, 100, 0, 4095));  // Reduce speed to 10% for homing
    }
    lastTriggerTime = currentTime;
  }
}

void findHomePosition() {
  unsigned long homeStartTime = millis();
  bool homeFound = false;

  Serial.println("Searching for home position...");
  analogWrite(DAC0, map(10, 0, 100, 0, 4095));  // Reduce speed to 10% for homing

  while (millis() - homeStartTime < 10000 && !homeFound) {
    // Here you would check the sensor to detect the home position
    // Assuming a sensor returns LOW when home is found
    if (digitalRead(pinHallSwitch) == LOW) {
      homeFound = true;
      Serial.println("Home position found.");
    }
  }

  if (!homeFound) {
    Serial.println("Failed to find home position.");
  }

  analogWrite(DAC0, 0);  // Stop the motor if home is not found or after homing
  digitalWrite(pinHomeLight, homeFound ? LOW : HIGH);  // Indicate home status with a light
}

void checkRideTimeout() {
  if (millis() - rideStartTime > rideDuration) {
    Serial.println("Ride duration complete.");
    analogWrite(DAC0, map(10, 0, 100, 0, 4095));  // Slow to home position
    delay(10000);  // Wait for home position
    analogWrite(DAC0, 0);  // Stop the motor
    rideActive = false;
    findHomePosition();
  }
}

void handleRideDurationSwitch() {
  if (digitalRead(pinDurationSwitch) == HIGH) {
    rideDuration = 45000;
  } else {
    rideDuration = 90000;
  }
}

void startRide() {
  rideStartTime = millis();
  rideActive = true;
  Serial.println("Ride Started");
}
2 Comments
2024/05/01
23:38 UTC

58

Any feedback on this circuit?

I'm just getting into wiring small projects. This is a 12v LED controller using an ESP8266 (formerly Arduino nano, but this is a bit cheaper). I'm currently using an IRFZ44N MOSFET to control the light. 12v goes in to a buck converter, the 5v out to the controller, PWM to the MOSFET and then a common ground to the buck converter amd 12v LEDs.

I have this wired, and it works quite well. I'm just looking for the seal of approval before I make a small PCB to make a dozen or so of these.

I don't have any resistors. Should I? Is the IRFZ44N the best fit for this? I have no idea. I'm just seeing what sticks at this point.

26 Comments
2024/05/01
23:32 UTC

2

Driver for 3.6v DC motor

Hi.

I'm looking to rebuild my old RC monster truck that it's not working anymore and one of the points that I'm in doubt is about the motor driver to use for the steering. This RC car uses a 3.6v DC motor with a potentiometer instead of a servo. Does anyone know or recommends a driver for this motor?

I've been looking L293 and L298 but I'm not sure if they are good for such low voltage motor. L293 for what I found it can't handle less than 4.5v motor...

5 Comments
2024/05/01
22:13 UTC

1

Are there any projekts around wireless audio?

I want to build my own wifi/bluetooth speaker, but I can't find any projects that works with arduino. All the projekts I find, are talking about using arduino IDE, and an ESP32. I know the Squeezelite for eps32, but the esp32 I have, don't have any PSRAM, which is needed.
I have an Arduino nano RP2040 and an Arduino Uno Wifi Rev2.

3 Comments
2024/05/01
21:47 UTC

0

Help with MPU6050 -> Neopixel LED Strip

Goal of this project is for when the gyro twists the led strip will light up. Goal for the final product is to have the gyro act as a toggle for multiple colors when twisted. Currently I'm not having much luck with the basics so here is the code, lmk if I got anything wrong:

// from: https://www.thingiverse.com/thing:4730334

#include <Adafruit_NeoPixel.h>
#define LED_COUNT 144
#define LED_PIN    9
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_MPU6050 mpu;
int colorMode = 0;
int x = 0;

// Use pins 2 and 3 to communicate with DFPlayer Mini


// Create the Player object

void setup() {
pinMode(8,OUTPUT);

strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
Serial.begin(9600);
  while (!Serial)
    delay(10); // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("Adafruit MPU6050 test!");

  // Try to initialize!
  if (!mpu.begin()) {
    Serial.println("Failed to find MPU6050 chip");
    while (1) {
      delay(10);
    }
  
  }

 Serial.println("MPU6050 Found!");

  mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
  Serial.print("Accelerometer range set to: ");
  switch (mpu.getAccelerometerRange()) {
  case MPU6050_RANGE_2_G:
    Serial.println("+-2G");
    break;
  case MPU6050_RANGE_4_G:
    Serial.println("+-4G");
    break;
  case MPU6050_RANGE_8_G:
    Serial.println("+-8G");
    break;
  case MPU6050_RANGE_16_G:
    Serial.println("+-16G");
    break;
  }
  mpu.setGyroRange(MPU6050_RANGE_500_DEG);
  Serial.print("Gyro range set to: ");
  switch (mpu.getGyroRange()) {
  case MPU6050_RANGE_250_DEG:
    Serial.println("+- 250 deg/s");
    break;
  case MPU6050_RANGE_500_DEG:
    Serial.println("+- 500 deg/s");
    break;
  case MPU6050_RANGE_1000_DEG:
    Serial.println("+- 1000 deg/s");
    break;
  case MPU6050_RANGE_2000_DEG:
    Serial.println("+- 2000 deg/s");
    break;
  }

  mpu.setFilterBandwidth(MPU6050_BAND_5_HZ);
  Serial.print("Filter bandwidth set to: ");
  switch (mpu.getFilterBandwidth()) {
  case MPU6050_BAND_260_HZ:
    Serial.println("260 Hz");
    break;
  case MPU6050_BAND_184_HZ:
    Serial.println("184 Hz");
    break;
  case MPU6050_BAND_94_HZ:
    Serial.println("94 Hz");
    break;
  case MPU6050_BAND_44_HZ:
    Serial.println("44 Hz");
    break;
  case MPU6050_BAND_21_HZ:
    Serial.println("21 Hz");
    break;
  case MPU6050_BAND_10_HZ:
    Serial.println("10 Hz");
    break;
  case MPU6050_BAND_5_HZ:
    Serial.println("5 Hz");
    break;
  }

  Serial.println("");
  delay(100);

strip.begin();
}




void loop() {
strip.clear();
/* Get new sensor events with the readings */
  sensors_event_t a, g, temp;
  mpu.getEvent(&a, &g, &temp);

  /* Print out the values */
  Serial.print("Acceleration X: ");
  Serial.print(a.acceleration.x);
  Serial.print(", Y: ");
  Serial.print(a.acceleration.y);
  Serial.print(", Z: ");
  Serial.print(a.acceleration.z);
  Serial.println(" m/s^2");

  Serial.print("Rotation X: ");
  Serial.print(g.gyro.x);
  Serial.print(", Y: ");
  Serial.print(g.gyro.y);
  Serial.print(", Z: ");
  Serial.print(g.gyro.z);
  Serial.println(" rad/s");

  Serial.println("");
  delay(100);
if(g.gyro.y > .1){ //If statement for Twist effect to change colors
    for(int i=0;i<LED_COUNT;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    strip.setPixelColor(i, strip.Color(150,150,150)); // Barbie Pink

    strip.show(); // This sends the updated pixel color to the hardware.
  //insert hitting sound
}

}
}
1 Comment
2024/05/01
21:36 UTC

1

ESP32 6c board powered with 3.7 v li-po battery?

Hello there!

I’m thinking to buy this board

https://www.dfrobot.com/product-2778.html

To connect to this battery

https://tinycircuits.com/products/lithium-ion-polymer-battery-3-7v-70mah

Any one have experience with this batteries? I hace read that could be dangerous because can set fire??

Any recommendations?

0 Comments
2024/05/01
18:19 UTC

2

help with OSC messages via ESP9266 and Arduino

I've played a bit and built whole system using OSC communication using CPP(liblo OSC) and C#(OSC jack or OSC core) and python. but now am In need to send OSC messages from my :
* Arduino mega2560 (no built in wifi)
* connected to ESP8266-01 NON-OS (either using AT instructions directly or via an ardunio library)
am sending to another machine on the same local network. I've read some of the docs for AT instruction set but so far am not able to send OSC messages via local network (there is alot of examples via serial communication but i dont think i could send to wireless messages with it if there is any one using sockets or plain AT commands I think would work!)

let me know if there is any info I can provide. I would appreciate any help or docs that could help me do that

take care <3

3 Comments
2024/05/01
19:12 UTC

0

Websocket client messages colliding with each other?

Hey guys so I'm working with an esp32, arduino sensors and the Arduino IDE.

Right now Im just sending messages from clients to the websocket server.

The clients connect fine, but when some messages are sent at the exact same time, its like only 1 gets through and makes it to the websocket server.

Is this a thing when working with websockets? What if I have 10 messages sent from either an esp32 or arduino board to the server at the same time?

2 Comments
2024/05/01
18:29 UTC

Back To Top