/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

674,622 Subscribers

1

I want to learn Arduino for a specific function. How should I get started?

I want to build a device to support a board game I'm working on that has a function similar to Hot Shots Golf's power meter

Is there a good starter kit or resources I should look to start with that would enable me to build a device with this behavior?

0 Comments
2024/11/21
19:03 UTC

0

Ask help converting firmware.

Hello everyone,
I contact you today for asking some help!

I'm a beginner, I'll use a arduino nano for get values, analyse with firmware and 'write' analysed values on other arduino pins.

Context :

First of all, It's an oxygen sensor(wideband) used in cars. This sensor need a firmware for control it(here for more details how work).
There is some project about it on web, but its contain only 'ended' chip version, no usb for modify firmware.
I have a kicad version of arduino nano and I will integrate it on my motherboard(Engine management system).

For firmware I got this written in C. Originally on PsOC Designer. This code allow to show values on external screen. not for my need, do you think he can convert to arduino? I know Its the same language. I need someone for explain me this code+convert it for arduino libs/.h.

(I got another firmware for atmega, my needs stay the same)(here).
This works can be paid.

Thanks everyone>!​!<

0 Comments
2024/11/21
17:10 UTC

1

Beginner Help - Parts List

Hi everyone -

I'm refurbishing a bubble hockey table and want to update it's electronics using an Arduino controller. I'm looking to do the following.

Inputs

- (2) dry contact reed switches to determine if a goal is scored.

- (6) push button inputs to trigger a "Boo" "Cheer" "Song" for each team

Outputs

- (2) dry contact outputs to relay onto the manufacturer score board (basically relay the reed switches on to the original score board)

- (1) dry contact to trigger a timed RED beacon for when goals are scored

- MP3 audio outputs will be played based on the input events (goal score sounds, Boo, Cheer, Songs)

I understand I likely need a basic Arduino and likely a DAC and output relay board maybe? This is where I'm lost. Is there an easy setup I can buy that will help with wiring all this up instead of using a breadboard or soldering? I assume I can figure out the programming since it's basic, but I'm lost with the hardware. Any advice is appreciated.

0 Comments
2024/11/21
13:50 UTC

1

I need help with the MIDI connection in my electronic drum project

Hello, everyone! Good evening. I'm working on an Arduino project, specifically an electronic drum kit, and I'm struggling quite a bit to make it work. I don't have much knowledge in this area, but I'm trying to overcome this challenge. (idk if i'm using the right flag, so sorry if its wrong)

The problem is that I can't make the connection between the serial port data and the audio program. I'm using Hairless MIDI as a "bridge," loopMIDI as a virtual port, and LF Studio to play the instrument sounds.

I want that when there is contact with the piezo sensor, Hairless communicates with LF Studio to trigger a note for a musical instrument. In the Hairless terminal, it seems not to recognize the touch on the sensor, and sometimes messages like the following appear:

Error: got unexpected data byte 0x0
Error: got unexpected data byte 0x78
Error: got unexpected data byte 0x18

I'm not sure if it's a problem with the code or the circuit assembly (I believe it's the first option). I really appreciate any help

int PadNotes[2] = {32, 38}; // notas
int sensorPins[2] = {13, 12}; // Pinos digitais
void setup() {
  Serial.begin(57600);
  for (int i = 0; i < 2; i++) {
    pinMode(sensorPins[i], INPUT_PULLUP);
  }
}

void loop() {
  for (int i = 0; i < 2; i++) {
    if (digitalRead(sensorPins[i]) == LOW) {
      MIDI_TX(144, PadNotes[i], 127); // MIDI Ligado - Toca a nota
    } else {
      MIDI_TX(128, PadNotes[i], 0); // MIDI Desligado - Sem som
    }
  }
  delay(50);
}
void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY) {
  Serial.write(MESSAGE);  // Envia o tipo de mensagem MIDI
  Serial.write(PITCH);    // Envia a nota MIDI
  Serial.write(VELOCITY); // Envia a intensidade (volume)

https://preview.redd.it/ckwj7kkk992e1.jpg?width=495&format=pjpg&auto=webp&s=1e037418556481bbeddcb2224baba314edc2667d

0 Comments
2024/11/21
13:18 UTC

1

how to create a clone motor axis using the Arduino Mega with Ramps1.4

To those that know; On the Arduino CNC shield used with the Arduino Uno there is an X, Y, Z and an A axes. The A axes can be used as a clone for X,Y or Z to run two stepper motors at the same time . The clone setup is done easily with jumper pins. Is there any way to do this with the Arduino mega/Ramps 1.4 combination? Perhaps using the EO or E1 Axis? I knox the Z axis has a second set of pins for a second stepper motor BUT in that case , the two motors are being driven by only one driver.I would refer two drivers.

Thanks for any insights John

0 Comments
2024/11/21
12:54 UTC

0

How to connect a MIDI sound module to a microcontroller via MIDI?

Hi everyone!

I’m planning to connect a MIDI sound module (like the Korg Volca Sample) to a microcontroller, but I’m having trouble figuring out exactly what cables or adapters I need. I’ve already set up a touchscreen and am using an Adafruit breakout for touch input, but I’m unsure about the next steps. My goal is to, for example, change the sound pitch by touching higher on the Y-axis of the screen.

Here are the components I’m using:

Can anyone advise me on the right MIDI controller and the software and hardware needed to make this work? I’d prefer to use a hardware MIDI controller so I’m not tied to a computer.

Thanks a lot for your help! 😊

1 Comment
2024/11/21
11:52 UTC

1

Unlocking the Power of the ATtiny85: My Journey from Simple to Complex Projects

My Journey with the ATtiny85: Tiny Size, Big Potential

When I first heard about the ATtiny85, I thought, “What can this tiny 8-pin chip really do?” Fast forward a few months, and it has become one of my favorite microcontrollers for compact, low-power projects. From simple LED blinkers to more complex creations, the ATtiny85 has pushed me to think creatively and maximize efficiency in my designs.

Here’s a look at some of my experiences, challenges, and projects that highlight just how capable this little chip can be.

Discovering the ATtiny85

I stumbled across the ATtiny85 while searching for a microcontroller to power a small, battery-operated project. At just a few dollars, it seemed perfect for projects that didn’t need the full power of an Arduino. Despite its small size and limited resources, it surprised me with its versatility and ability to handle surprisingly complex tasks.

Complex Projects I Built with the ATtiny85

  1. Digital Thermometer with OLED Display

For this project, I combined the ATtiny85 with a small I²C OLED display and a digital temperature sensor (like the DS18B20). The ATtiny85 handled the sensor data, calculated the temperature, and displayed it on the screen.

Challenges Faced:

Working with I²C on the ATtiny85 required careful optimization of memory and code.

Managing the limited RAM (512 bytes) meant minimizing the size of the fonts and graphics for the OLED.

Why It Worked: The ATtiny85’s 8 KB Flash memory was enough to store the code, and its low power consumption made it ideal for a battery-operated thermometer.

  1. USB HID Media Controller

I wanted to build a custom USB media controller that could play, pause, or skip tracks on my PC. Using the V-USB library, I turned the ATtiny85 into a USB HID device. With just a few buttons wired to the GPIO pins, the ATtiny85 sent pre-programmed keystrokes to control media playback.

Challenges Faced:

Configuring V-USB was tricky because the ATtiny85 doesn’t have native USB support.

Ensuring the timing and communication adhered to USB protocol standards required fine-tuning.

Outcome: It worked perfectly! I programmed specific key combinations for media control, and the ATtiny85 seamlessly interacted with my PC.

  1. Motion-Activated Night Light

For a more practical project, I created a motion-activated night light. Using a PIR motion sensor, the ATtiny85 detected movement and powered an LED strip. I implemented a sleep mode for power saving, waking the microcontroller only when motion was detected.

Key Features:

Adjustable timer to turn off the light after a set duration.

PWM control to dim the LEDs gradually.

Ultra-low power draw in sleep mode.

Challenges Faced:

Integrating the PIR sensor required careful pin management, as the ATtiny85 has limited GPIOs.

Sleep modes required precise configuration to ensure reliable wake-up triggers.

  1. Simple Music Synthesizer

Using the ATtiny85’s PWM capabilities, I created a mini synthesizer that generated simple tones. By connecting a piezo buzzer and using predefined frequency values for musical notes, I programmed it to play basic tunes like "Happy Birthday" or even a mini alarm.

Advanced Features:

Buttons were used to control pitch and duration in real-time.

The program could store custom tunes in EEPROM for playback.

Challenges Faced:

Managing multiple buttons with limited GPIO required creative wiring and multiplexing.

Generating smooth tones with consistent timing was a learning curve but rewarding.

  1. RGB LED Controller with Infrared Remote

For this project, I used the ATtiny85 to control an RGB LED strip. The microcontroller read signals from an infrared (IR) remote, decoded them, and adjusted the LED colors accordingly.

Features:

Pre-set color modes controlled via the remote.

Brightness adjustment using PWM.

Smooth transitions between colors.

Challenges Faced:

Decoding IR signals required precise timing, which pushed the ATtiny85’s processing power to its limits.

The program had to fit within the memory constraints while still offering multiple modes.

Why I Loved It: The ATtiny85 handled the task beautifully, and I was able to create a compact and affordable LED controller that worked flawlessly.

What I Learned from These Projects

  1. Memory Management is Key:

The ATtiny85’s limited RAM and Flash forced me to write clean, optimized code. This was a valuable lesson for all my future projects.

  1. Creative Pin Usage:

With only 6 GPIO pins, I had to get creative. Multiplexing, using I²C peripherals, and even sharing pins between components taught me how to maximize hardware.

  1. Low Power, High Efficiency:

I gained a deep appreciation for low-power design. Using sleep modes and efficient algorithms, I was able to stretch battery life in projects like the motion-activated light.

Why the ATtiny85 is Still My Go-To Microcontroller

Even though I now work with more powerful boards like the ESP32 or Raspberry Pi Pico, the ATtiny85 remains a favorite for compact, minimalist projects. It’s affordable, reliable, and forces me to think critically about design and resource management.

If you’re looking for a challenge or want to explore how much you can do with limited resources, I highly recommend giving the ATtiny85 a try.

Your Turn ! Have you worked with the ATtiny85? What’s the most interesting project you’ve built with it? Or are you curious about getting started? Share your experiences, questions, or ideas below—I’d love to hear them!

0 Comments
2024/11/21
09:16 UTC

0

Distance sensor recommendation

I want to measure the inside length and width of a rectangular fuel storage tank. To do this, I want to drop a sensor down through an opening in the top and rotate it around to shoot the distances at various angles. What would the best sensor be to accomplish this? There is about 6 inches of space between the fuel and the top of the tank. My worry is that for the longer lengths (~12ft/4m) the beam will be wide enough to hit the fuel and the top of the tank and mess up the measurement. I have found a couple of lidar sensors that I think might work but I am not sure. They are the TF-Luna and TFmini-S. Anybody have experience with these sensors or recommend another lidar sensor for this applications? I am looking for something accurate to 1 inch, narrow FOV, and under $100. Thanks!

2 Comments
2024/11/21
12:48 UTC

0

How to connect this?

I'm New at ardiunos and and coding and need help converting this to the bread board, does anyone have a idea on how to do this? Thanks in advance!!

9 Comments
2024/11/21
12:03 UTC

1

Gprs vs lora for long range coms

Currently have a project that takes data from a neo 6m (long and lat) and then I need it to be uploaded to my computer from the modual. I currently have a sim800l interfaces to get the coordinates when periodically sent to my phone and an nrf2401 to send the coordinates all the time to my computer to be uploaded to the mapping software but I want to improve the range.

I’m under the influence that a LORA modual will provide about 15km range to the project with about 5k in urban settings which is good but there’s also the gprs root where I can upload directly to the website. Was wondering which methods people on here would be opting for as the gprs means I have extended range but I’m not too sure what people will say and if I’m overlooking something simple.

Thanks in advanced :)

2 Comments
2024/11/21
11:59 UTC

0

How should I connect the GND VCC JD-VCC pins of the Relay Board

The left VCC and GND is from the breadboard power supply which is 5v tone done by a 12V by a regulator (4th image). I am also using that breadboard power supply to power my ESP32 (got burnt). It had the blue connector connecting VCC with VCC-JD. What should I do so that I control the relay using the IN pins without burning my ESP32. I put both inputs as the same channel but different relays as one is using AC120V and another is DC12V.

0 Comments
2024/11/21
11:33 UTC

1

Remote Pasword System (project)

In the modern day there are 4 most used ways to use remote controll between 1 electronic computers, Bluetooth, Wifi, Rfid and radio frequenty. Now you can do these with a flipper zero with ESP mod, for 300€ (in my country), wich is a lil out of my budget

Now I am going to build this myself using my fav compny, M5stack. Now the one i am going to use, is a esp32, so wifi and bluetooth is easy. Found by the same company going to use a RFID scanner and sender.

But now radio freqwenty. I am a prof drone pilot so I know what the drone use, but not my car key and garage door. What frequenty modules should i put? Looking on m5stack site there are a lot

0 Comments
2024/11/21
11:30 UTC

5

Purpose of this button form factor

https://preview.redd.it/o86266bil82e1.png?width=1000&format=png&auto=webp&s=453b6a92817cb9b7e955008c7757b2cf3b650f4f

Hello, I hope this isn't a silly question as i'm starting learning Arduino for my little project. I have a bunch of these buttons from a kit, and I’m curious about the purpose of this specific form factor. I’m currently building a control panel for a 3D scanner turntable, and I’m wondering if these buttons are primarily meant for quick breadboard prototyping. I’m struggling to think of a practical way to integrate them into any kind of enclosure I can visualize. Do you have any exemple of how you are using them ?

I purchased those others buttons which are easier to integrate as I can just tighten the nut, but they require soldering. What kind of buttons do you use in an enclosure ?

https://preview.redd.it/hc3zx0ncm82e1.png?width=3072&format=png&auto=webp&s=25550ae161e209e23d373477542ace0894fc6757

https://preview.redd.it/tkcll8l3m82e1.png?width=3072&format=png&auto=webp&s=ac74efa13c7e5aab6653c5c074935c8540616816

7 Comments
2024/11/21
11:16 UTC

0

How to make a Maze Solver

I need to make a maze solver, for the very first time. The worst part is, it's for a competition. I am under the water, please help me.

I will be using one of those "anti-gravity" toy cars due to their suction ability allowing for high precision when turning. I also want to use a camera with a raspberry pico. The motors will be controlled using a mini L293N. I also have a MPU6050 available. Would that be enough?

9 Comments
2024/11/21
09:15 UTC

0

why arent AT commands working on my hc05 slave-master transmitter?

i'm trying to configure two hc05 transmitters but when i try to use AT commands it says "Error:(0)" in every single command. the only command it says "OK" to is when i type AT. I configured it to 9600 baud and NL & CR. please help as this is urgent.

0 Comments
2024/11/21
09:09 UTC

7

Building a "Smart Climbing Wall" – Need Advice on Buttons!

Hi everyone,

I’m building a "Smart Climbing Wall" where each climbing hold lights up with an LED and has a button to press when you reach it.

I’m thinking of using piezo sensors as the buttons, but I’m not sure if they’ll last long or if I’ll need to keep fixing them all the time.

What do you think? Are piezos a good choice, or is there something better?

https://preview.redd.it/rx57lipva72e1.jpg?width=1600&format=pjpg&auto=webp&s=6125dba4fb40e30fd3f7560802dca6a669b869ae

7 Comments
2024/11/21
06:43 UTC

2

Esp32 not showing in com ports

I've installed the cp210x drivers uninstall ed and reinstalled tried all the windows versions tried ch4ser one as well and it still won't appear. I had it working then the board suddenly turned off and the led only comes on now if I hold en but that's another issue so I switched to a new board but it won't connect at all now Any ideas? Thank you

Edit: I solved the problem not sure on the exact cause or why it worked before but I connected it to a power supply unit and it all started to work

2 Comments
2024/11/21
06:36 UTC

2

Multiple buttons single pin

Hi i made this project on wokwi(https://wokwi.com/projects/414874509761902593) and i want all the buttons on the same pin but i am so confuse how to do it. i try to learn following some tutorials online adapting the same wiring schematic on the tutorials to my project and nothing any help please thanks

5 Comments
2024/11/21
06:14 UTC

25

I tried soldering for the first time so its not that clean, but is there any chance that led will stop working if I accidently heat the head of the led for just a moment?

kinda afraid of it

19 Comments
2024/11/21
06:03 UTC

9

Candle Flicker Help

I'm on a mission to create a better candle flicker. I've experimented with various iterations using the random PWM output and they are OK but not what exactly I'm looking for. The function shown in the attached photo produces an incredibly smooth, stepless, and realistic simulation of a candle flicker when used to control an incandescent light bulb. I pulled it from my lighting console.

Can anyone point me in the right as to how to create a function that would essentially mimick what is shown in this graph? I have basic Arduino coding skills, but I lack the maths skills needed to create this sort of random time/intensity function with smooth transition on the Y axis.

Thanks!

7 Comments
2024/11/21
04:09 UTC

2

Grove SGP30 eCO2 sensor in matlab issues

I am a first year engineering student, and I am very new to arduino, and in fact I only am interested due to one of my courses where in matlab we learn to utilize the grove beginner arduino kit (nano3 board) and other attachments such as a moisture sensor, a water pump, and a co2 sensor (grove SGP30). Since matlab is not the language the designers intended to use, our prof had to create a matlab library for the sensor to output co2 levels in ppm. This would be fantastic if not for the fact that when attempting to collect samples with a set pause between samples, always at some point (as in sample ~60 of 1000) the library will throw a CRC error, as shown below. When I attempted to remove the block that threw the error in the library, the second error below appears, meaning there is an issue with the library itself.

% CRC error:
CRC error 133 != 245 for crc check 1

% error with CRC error block removed from library:
Unable to read the data from the I2C device. Check the connections between the hardware and device, For MATLAB clear the device object and try again.

My professor told us if we encounter the CRC error we can try to 1: increase pause time between sample collections (as in from 0.05sec to 1sec smh) or 2: fiddle with the timings in the matlab library as shown below.

%I2C Delay
        Delay4IAQInit = 10;           %ms Not defined in Datasheet  uses 10ms
        Delay4ReadAirQuality = 2;     %Typ.2ms  Max.10ms
        Delay4ReadSerialNumber = 10;  %Typ.10ms Max.12ms
        Delay4GetBaseline = 10;       %Typ.10ms Max.10ms
        Delay4SetBaseline = 10;       %Typ.10ms Max.10ms
        Delay4SetHumidity = 1;        %Typ.1ms  Max.10ms
        Delay4MeasureTest = 200;      %Typ.200ms Max.220ms
        Delay4GetFeatureSet = 1;      %Typ.1ms  Max.2ms
        Delay4MeasureRawSig = 20;     %Typ.20ms Max.25ms
        %CRC
        crc8Polynomial = 0x31;
        crc8Init = 0xFF;

Nothing I try to change in the delay menu works, but I might have to set super specific timings that I am unaware of.

This is the crc function from my profs library if someone understands what's flying.

function crcOut = generateCrc(obj,data)
        obj.logme(dbstack,' ');
        % https://www.mathworks.com/help/matlab/matlab_prog/perform-cyclic-redundancy-check.html
        % Online calculator: http://www.sunshine2k.de/coding/javascript/crc/crc_js.html 
        crc = sgp30.crc8Init;               %SGP30 crc8Init is 0xFF;
        polynomial = sgp30.crc8Polynomial;   %SGP30 crc8Polynomial is 0x31
        for k= 1:length(data)
            bt = uint8(data(k));
            crc = bitxor(crc,bt);
            for  i = 1:8
                test = bitand(crc,0x80);
                if test ~= 0 
                    crc = bitxor(bitshift(crc,1),polynomial); 
                else
                    crc = bitshift(crc,1);
                end
            end
        end
        crcOut = bitand(crc,0xFF); %Converts to uint8
        % SGP30 Datasheet Example CRC: 0xBEEF = 0x92
    end

Nothing I try to change here works. Any suggestions would be greatly appreciated since my lab report with the sensor is due on sunday.

0 Comments
2024/11/21
02:06 UTC

0

first time using PCF8574 - trouble shooting

I'm trying to get my arduino nano to read through the PCF8574 when 8 select lines go high in a pre-midi music keyboard. One possible problem is I don't know if it is a PCF8574 or A. I bought these. My code is below.

I'm using the library from xreef.

5V and GND via Nano, SDA-A4 SCL-A5, int-D2

From the Serial Monitor I get lots of "S: 0000000". So I read that as the interrupt pin is firin (which it should, there'll be a state change every approx 50micro seconds), but I'm not getting the output correctly

#include "PCF8574.h"

/* * PCF8574
 * J1 - KO1  - P0 (Select In 1)
 * J6 - KO2  - P1 (Select In 2)
 * J7 - KO3  - P2 (Select In 3)
 * J8 - KO4  - P3 (Select In 4)
 * J9 - KO5  - P4 (Select In 5)
 * J10 - KO6 - P5 (Select In 6)
 * J11 - KO7 - P6 (Select In 7)
 * J12 - KO8 - P7 (Select In 8)
 * 
 */

// Function Interrupt
void keyPressedOnPCF8574();

PCF8574 pcf8574(0x38, 2, keyPressedOnPCF8574); //PCF8574 interrupt connected to D2
bool keyPressed = false;

void setup() {
  // put your setup code here, to run once:
  for(int i=0;i>8;i++){
    pcf8574.pinMode(i,INPUT);
  }
  pcf8574.begin();
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(keyPressed){
    PCF8574::DigitalInput selectIn = pcf8574.digitalReadAll();
    Serial.print("S: ");
    Serial.print(selectIn.p0);
    Serial.print(selectIn.p1);
    Serial.print(selectIn.p2);
    Serial.print(selectIn.p3);
    Serial.print(selectIn.p4);
    Serial.print(selectIn.p5);
    Serial.print(selectIn.p6);
    Serial.println(selectIn.p7);
    keyPressed=false;
  }
}
void keyPressedOnPCF8574(){
  keyPressed=true;
}
9 Comments
2024/11/21
01:32 UTC

0

Need a double checking on a coding

Hey everyone,

I'm close to finishing a project I’ve been working on for months! However, coding is now the only thing I need to finish. My entire setup is perfect; everything is working (I only need to purchase the correct batteries). But before I go full throttle on the project, I wanted to ask if someone can double-check the coding for this project before I kick off with it, please.

I’m entirely new to the game and coding is not of my expertise.

For Hardware, I’m using:

An Arduino Nano A NOYITO I O Expansion Sensor Shield Module for UNO R3 Nano V3.0 Nano Pro Four Beffkkip SG90 9g Micro Servos for RC Robot Helicopter Airplane Controls Car Boat motors A DWEII IR remote 17 button system

For Software, I used a combo of Arduino and Otto Blockly.

This project's goal is to have a small robot I designed to move on an IR remote. I already did a test run with the IR remote function (which was successful) but now getting the bot moving via buttons is the next hurdle.

For the coding itself, I used a combination of the coding for the IR remote and some minor codings from Otto Blockly (hence why there’s a lot of the word ‘Otto’ thrown around)

Verifying-wise, Arduino said it was good to go, but I wanted to ask someone who was in this game a lot longer if they could look over the code and see if there are any mistakes to it and what could be changed. I have the link to the coding below and photos of my setup up as well as schematics for safety!

Thank you in advance!

https://pastebin.com/U3KhaPGx

https://preview.redd.it/exy00utxn52e1.jpg?width=3024&format=pjpg&auto=webp&s=0581755db52a3c178adf973631793b4ff8e785ed

https://preview.redd.it/3p2pyiuxn52e1.jpg?width=1280&format=pjpg&auto=webp&s=f537de823f5477786f4c10d42724fbedbd09c303

8 Comments
2024/11/21
01:14 UTC

3

Help Needed: Stepper Motor Not Rotating Correctly in Senior Design Project

Hi everyone,
I’m working on a senior design project to create an automated toilet seat lifter. Our setup includes:

  • Components:
    • Stepper motor: NEMA 17 with 5:1 planetary gearbox
    • Stepper driver: DRV8825
    • Motor shield, Arduino Uno
    • Potentiometer (for current adjustment)
    • Ultrasonic sensor (for motion detection)
    • 11.4V lithium battery power source

I’ve attached pictures of our setup and included the code we’re using to run the motor.

The issue:
When we run the code, the motor activates (you can feel vibrations and hear it working), but the shaft does not rotate as expected. Instead, it sputters, shakes, or vibrates without stepping correctly. We are unsure if the issue we have is physical (i.e. missing wires in our setup), code-based (we are missing code or wires/pins listed incorrectly), or another issue (power supply, etc).

What we’ve checked:

  1. Potentiometer setup:
    • The motor is rated at 1.58A/phase, so we’ve set the DRV8825’s current limit to 0.79V as per the formula.
    • The motor's spec sheet is here under Downloads.
    • Here is the schematic for the potentiometer we are using:

https://preview.redd.it/t0i5qkt6j52e1.png?width=600&format=png&auto=webp&s=a7ce27e750e81f7fae9d834bac842596e9d76f51

  1. Power supply:
    • The motor shield is receiving 11.4V, confirmed with a multimeter.

Photos:

Entire setup: arduino uno on bottom, shield on top, potentiometer and battery connected. Motor connected. ultrasonic sensor disconnected

close up of pins and connections

Code:

#include <AccelStepper.h>

// Define pins for the X-axis motor

#define stepPin 2

#define dirPin 5

// Create an AccelStepper object

AccelStepper stepper(AccelStepper::DRIVER, stepPin, dirPin);

void setup() {

Serial.begin(9600);

Serial.print("Current Position: ");

Serial.println(stepper.currentPosition());

// Set maximum speed and acceleration

stepper.setMaxSpeed(500); // steps per second

stepper.setAcceleration(250); // steps per second^2

// Set initial position

stepper.setCurrentPosition(0);

}

void loop() {

// Move 1000 steps forward

stepper.moveTo(200);

stepper.runToPosition(); // Blocking call, motor moves to position

delay(1000); // Wait 1 second

// Move 1000 steps backward

stepper.moveTo(0);

stepper.runToPosition(); // Blocking call, motor returns to position

delay(1000); // Wait 1 second

}

My group has a mechanical engineering background, so we’re less familiar with the electrical side of things. Any advice on why the motor isn’t stepping correctly and how to fix it would be greatly appreciated!

7 Comments
2024/11/21
01:00 UTC

916

It can now be controlled remotely! :D

42 Comments
2024/11/21
00:23 UTC

3

Call from arduino?

I missed a call today and when I listened to the voicemail it was someone claiming to be with arduino?? Said they were just calling to see if they could help out and that a gabe or Gabriel would be emailing me. Then said something about deals until the end of the year. Super weird has anyone else every received anything like this before? I did get the engineering kit a little while back. I went to the arduino website contact and sent them a message asking about the phone calls validity but no response yet. Just curious as to if anyone else has had anything similar?

7 Comments
2024/11/20
22:45 UTC

3

Huge engineering project

Hi all, I’m doing an arduino based engineering project and I’m in need of some help. I’m wanting to take diagnostic codes from a car have them read by the arduino and then have the arduino communicate back what parts need replaced. I have the translations from code number to part(s) need to be replaced or examined but am uncertain how to add this data base to the arduino and how I can have the arduino take the given codes and spit back the diagnosis. My idea is to use arduino to read car diagnostics and also use sonar sensors, piezoelectric sensors, and a few other things to search for mechanical errors. All help is appreciated I understand if this is not achievable as well, thanks in advance!

15 Comments
2024/11/20
22:19 UTC

Back To Top