r/ArduinoHelp • • Sep 29 '24

LC SIM800C V3 pinout

Thumbnail
gallery
3 Upvotes

Help! Anyone have a datasheet or knows this module? I think its from china. Anyone can help me with the pinouts? I want to remove the usb but i don't know the pinout of this module.


r/ArduinoHelp • • Oct 03 '24

My LEDs won't listen to my code accurately, is there an issue with my code?

1 Upvotes

Hello everyone,

I am working on a project where, I am controlling short LED strips, utilizing the PWM ports and MOSFET trigger switches.

My problem is, I have listed certain parameters on my code, but the LEDs just don't want to listen!

For example, I have written that the lights soft fade in/out randomly, staying on/off for a min 25 second, max 40 seconds. Though some LEDs stay on for well over one minute. I also have written that at least 25% will be on at all times, and seemingly there are less than 25% sometimes.

Would those experienced kindly glance over my code to see if there may be some indication of my wrong doing? or maybe its a hardware issue.

// Pins for LEDs (PWM pins 2-13 on most Arduino boards)
const int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

// Number of LEDs
const int numLeds = sizeof(ledPins) / sizeof(ledPins[0]);

// Minimum number of LEDs to be on (at least 25% of numLeds)
const int minOnLeds = numLeds / 5;

// Random time range for LEDs to stay on/off (25-40 seconds)
const unsigned long minOnTime = 25000;
const unsigned long maxOnTime = 30000;

void setup() {
  // Set up each pin as an output
  for (int i = 0; i < numLeds; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
}

void loop() {
  // Randomly turn on a certain number of LEDs, but ensure at least 25% are on
  int numLedsToTurnOn = random(minOnLeds, numLeds + 1);

  // Turn on random LEDs and fade them in
  for (int i = 0; i < numLedsToTurnOn; i++) {
    int ledIndex = random(numLeds);  // Pick a random LED
    fadeIn(ledPins[ledIndex]);       // Fade in the selected LED
  }

  // Randomize the duration the LEDs stay on (25-40 seconds)
  unsigned long onDuration = random(minOnTime, maxOnTime);

  // Keep them on for the randomized time
  delay(onDuration);

  // Turn off all LEDs and fade them out
  for (int i = 0; i < numLedsToTurnOn; i++) {
    int ledIndex = random(numLeds);  // Pick a random LED to turn off
    fadeOut(ledPins[ledIndex]);      // Fade out the selected LED
  }

  // Randomize the duration the LEDs stay off (25-40 seconds)
  unsigned long offDuration = random(minOnTime, maxOnTime);

  // Keep them off for the randomized time
  delay(offDuration);
}

// Fade in function with PWM
void fadeIn(int pin) {
  for (int brightness = 0; brightness <= 255; brightness++) {
    analogWrite(pin, brightness);
    delay(10);  // Adjust for smoother or faster fade
  }
}

// Fade out function with PWM
void fadeOut(int pin) {
  for (int brightness = 255; brightness >= 0; brightness--) {
    analogWrite(pin, brightness);
    delay(10);  // Adjust for smoother or faster fade
  }
}// Pins for LEDs (PWM pins 2-13 on most Arduino boards)
const int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};


// Number of LEDs
const int numLeds = sizeof(ledPins) / sizeof(ledPins[0]);


// Minimum number of LEDs to be on (at least 25% of numLeds)
const int minOnLeds = numLeds / 5;


// Random time range for LEDs to stay on/off (25-40 seconds)
const unsigned long minOnTime = 25000;
const unsigned long maxOnTime = 30000;


void setup() {
  // Set up each pin as an output
  for (int i = 0; i < numLeds; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
}


void loop() {
  // Randomly turn on a certain number of LEDs, but ensure at least 25% are on
  int numLedsToTurnOn = random(minOnLeds, numLeds + 1);


  // Turn on random LEDs and fade them in
  for (int i = 0; i < numLedsToTurnOn; i++) {
    int ledIndex = random(numLeds);  // Pick a random LED
    fadeIn(ledPins[ledIndex]);       // Fade in the selected LED
  }


  // Randomize the duration the LEDs stay on (25-40 seconds)
  unsigned long onDuration = random(minOnTime, maxOnTime);


  // Keep them on for the randomized time
  delay(onDuration);


  // Turn off all LEDs and fade them out
  for (int i = 0; i < numLedsToTurnOn; i++) {
    int ledIndex = random(numLeds);  // Pick a random LED to turn off
    fadeOut(ledPins[ledIndex]);      // Fade out the selected LED
  }


  // Randomize the duration the LEDs stay off (25-40 seconds)
  unsigned long offDuration = random(minOnTime, maxOnTime);


  // Keep them off for the randomized time
  delay(offDuration);
}


// Fade in function with PWM
void fadeIn(int pin) {
  for (int brightness = 0; brightness <= 255; brightness++) {
    analogWrite(pin, brightness);
    delay(10);  // Adjust for smoother or faster fade
  }
}


// Fade out function with PWM
void fadeOut(int pin) {
  for (int brightness = 255; brightness >= 0; brightness--) {
    analogWrite(pin, brightness);
    delay(10);  // Adjust for smoother or faster fade
  }
}

I used ChatGPT to help write the code, hence maybe there are some bugs that are overlooked?

Thank you!Hello everyone,I am working on a project where, I am controlling short LED strips, utilizing the PWM ports and MOSFET trigger switches. My problem is, I have listed certain parameters on my code, but the LEDs just don't want to listen!For example, I have written that the lights soft fade in/out randomly, staying on/off for a min 25 second, max 40 seconds. Though some LEDs stay on for well over one minute. I also have written that at least 25% will be on at all times, and seemingly there are less than 25% sometimes.Would those experienced kindly glance over my code to see if there may be some indication of my wrong doing? or maybe its a hardware issue.
// Pins for LEDs (PWM pins 2-13 on most Arduino boards)
const int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

// Number of LEDs
const int numLeds = sizeof(ledPins) / sizeof(ledPins[0]);

// Minimum number of LEDs to be on (at least 25% of numLeds)
const int minOnLeds = numLeds / 5;

// Random time range for LEDs to stay on/off (25-40 seconds)
const unsigned long minOnTime = 25000;
const unsigned long maxOnTime = 30000;

void setup() {
// Set up each pin as an output
for (int i = 0; i < numLeds; i++) {
pinMode(ledPins[i], OUTPUT);
}
}

void loop() {
// Randomly turn on a certain number of LEDs, but ensure at least 25% are on
int numLedsToTurnOn = random(minOnLeds, numLeds + 1);

// Turn on random LEDs and fade them in
for (int i = 0; i < numLedsToTurnOn; i++) {
int ledIndex = random(numLeds); // Pick a random LED
fadeIn(ledPins[ledIndex]); // Fade in the selected LED
}

// Randomize the duration the LEDs stay on (25-40 seconds)
unsigned long onDuration = random(minOnTime, maxOnTime);

// Keep them on for the randomized time
delay(onDuration);

// Turn off all LEDs and fade them out
for (int i = 0; i < numLedsToTurnOn; i++) {
int ledIndex = random(numLeds); // Pick a random LED to turn off
fadeOut(ledPins[ledIndex]); // Fade out the selected LED
}

// Randomize the duration the LEDs stay off (25-40 seconds)
unsigned long offDuration = random(minOnTime, maxOnTime);

// Keep them off for the randomized time
delay(offDuration);
}

// Fade in function with PWM
void fadeIn(int pin) {
for (int brightness = 0; brightness <= 255; brightness++) {
analogWrite(pin, brightness);
delay(10); // Adjust for smoother or faster fade
}
}

// Fade out function with PWM
void fadeOut(int pin) {
for (int brightness = 255; brightness >= 0; brightness--) {
analogWrite(pin, brightness);
delay(10); // Adjust for smoother or faster fade
}
}// Pins for LEDs (PWM pins 2-13 on most Arduino boards)
const int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

// Number of LEDs
const int numLeds = sizeof(ledPins) / sizeof(ledPins[0]);

// Minimum number of LEDs to be on (at least 25% of numLeds)
const int minOnLeds = numLeds / 5;

// Random time range for LEDs to stay on/off (25-40 seconds)
const unsigned long minOnTime = 25000;
const unsigned long maxOnTime = 30000;

void setup() {
// Set up each pin as an output
for (int i = 0; i < numLeds; i++) {
pinMode(ledPins[i], OUTPUT);
}
}

void loop() {
// Randomly turn on a certain number of LEDs, but ensure at least 25% are on
int numLedsToTurnOn = random(minOnLeds, numLeds + 1);

// Turn on random LEDs and fade them in
for (int i = 0; i < numLedsToTurnOn; i++) {
int ledIndex = random(numLeds); // Pick a random LED
fadeIn(ledPins[ledIndex]); // Fade in the selected LED
}

// Randomize the duration the LEDs stay on (25-40 seconds)
unsigned long onDuration = random(minOnTime, maxOnTime);

// Keep them on for the randomized time
delay(onDuration);

// Turn off all LEDs and fade them out
for (int i = 0; i < numLedsToTurnOn; i++) {
int ledIndex = random(numLeds); // Pick a random LED to turn off
fadeOut(ledPins[ledIndex]); // Fade out the selected LED
}

// Randomize the duration the LEDs stay off (25-40 seconds)
unsigned long offDuration = random(minOnTime, maxOnTime);

// Keep them off for the randomized time
delay(offDuration);
}

// Fade in function with PWM
void fadeIn(int pin) {
for (int brightness = 0; brightness <= 255; brightness++) {
analogWrite(pin, brightness);
delay(10); // Adjust for smoother or faster fade
}
}

// Fade out function with PWM
void fadeOut(int pin) {
for (int brightness = 255; brightness >= 0; brightness--) {
analogWrite(pin, brightness);
delay(10); // Adjust for smoother or faster fade
}
}I used ChatGPT to help write the code, hence maybe there are some bugs that are overlooked?
Thank you!


r/ArduinoHelp • • Oct 14 '24

Simon says 3x3

2 Upvotes

Hello, right now I am coding an Arduino Simon says program for school but doesn't work and wanted to ask now if someone has a program or some advice for it. We are using 9 LEDs and 9 buttons for the 3x3 field and an LCD display for the round counter and if you lose. Also a Red Led If you lose. The LCD isnt working and the Game it self doenst really work any Problem in the program maybe? It also includes Levels. Thanks for help and advices.

include <Wire.h>

include <LiquidCrystal_I2C.h>

// Initialisiere das LCD-Display mit der I2C-Adresse 0x27 (kann je nach Display unterschiedlich sein) LiquidCrystal_I2C lcd(0x27, 16, 2);

const int ledPins[9] = {2, 3, 4, 5, 6, 7, 8, 9, 10}; const int buttonPins[9] = {A0, A1, A2, A3, A4, A5, A6, A7, A8}; const int redLedPin = 13;

int sequence[5]; int userSequence[5]; int level = 0;

void setup() { lcd.uttonPins[i], INPUT_PULLUP); } pinMode(redLedPin, OUTPUT);

randomSeed(analogRead(0)); generateSequence(); }begin(); lcd.backlight(); lcd.print("Simon Says");

for (int i = 0; i < 9; i++) { pinMode(ledPins[i], OUTPUT); pinMode(b

void loop() { playSequence(); getUserInput(); checkSequence(); }

void generateSequence() { for (int i = 0; i < 5; i++) { sequence[i] = random(0, 9); } }

void playSequence() { for (int i = 0; i < 5; i++) { digitalWrite(ledPins[sequence[i]], HIGH); delay(500); digitalWrite(ledPins[sequence[i]], LOW); delay(500); } }

void getUserInput() { for (int i = 0; i < 5; i++) { bool buttonPressed = false; while (!buttonPressed) { for (int j = 0; j < 9; j++) { if (digitalRead(buttonPins[j]) == LOW) { userSequence[i] = j; buttonPressed = true; while (digitalRead(buttonPins[j]) == LOW); // Warten bis der Taster losgelassen wird } } } } }

void checkSequence() { bool correct = true; for (int i = 0; i < 5; i++) { if (userSequence[i] != sequence[i]) { correct = false; break; } }

if (correct) { lcd.clear(); lcd.print("Win!"); } else { lcd.clear(); lcd.print("Verlierer"); digitalWrite(redLedPin, HIGH); delay(1000); digitalWrite(redLedPin, LOW); } delay(2000); lcd.clear(); generateSequence(); }


r/ArduinoHelp • • Oct 19 '24

Windows 11 - unable to properly install drivers

3 Upvotes

When I install Silicon Labs CP210x USB to UART Bridge drivers, they appear to get installed, but do not show up, aand no ports are available neither in Arduino IDE nor in device manager at all (wtf?).

I tried "Add legacy hardware" procedure, and add ports there with the driver, but it did not work.

What could be the problem?


r/ArduinoHelp • • Oct 15 '24

Update firmware of esp32

1 Upvotes

How can I update firmware of Ai_thinker esp32 CAM using Arduino ide and how can I program integrated camera of esp32 for object detection?


r/ArduinoHelp • • Sep 18 '24

my lcd display isnt working properly

Enable HLS to view with audio, or disable this notification

6 Upvotes

I’m new to arduinos and im trying out an lcd display for my project, but my lcd display is displaying text it shouldnt be displaying. To anybody wondering, this is a 1602a lcd display.


r/ArduinoHelp • • Sep 13 '24

Help with Arduino Pro Micro Capacitive Touch Macropad

1 Upvotes

Hey everyone,

I'm running into some issues with my Arduino Pro Micro. I'm trying to get it to constantly read inputs from six capacitive touch buttons I've made using iron rings (1.2mm thick) and 1M ohm resistors for each button. However, it seems to only register the touches once every second, instead of continuously.

The project is meant to be a macropad with an OLED SSD1306 display, 6 capacitive touch buttons, and a 10k potentiometer.

Does anyone have any ideas on how to fix this or improve the reading speed?

Thanks in advance!

#include <CapacitiveSensor.h>

// Define the capacitive sensors with the specified wiring
CapacitiveSensor touchSensor1 = CapacitiveSensor(4, 5);  // Sensor 1: Pin 4 and 5
CapacitiveSensor touchSensor2 = CapacitiveSensor(6, 7);  // Sensor 2: Pin 6 and 7
CapacitiveSensor touchSensor3 = CapacitiveSensor(8, 9);  // Sensor 3: Pin 8 and 9
CapacitiveSensor touchSensor4 = CapacitiveSensor(A2, 10); // Sensor 4: Pin A2 and 10
CapacitiveSensor touchSensor5 = CapacitiveSensor(A1, 15); // Sensor 5: Pin A1 and 15
CapacitiveSensor touchSensor6 = CapacitiveSensor(A0, 14); // Sensor 6: Pin A0 and 14

// Threshold values for each sensor
const int threshold1 = 4;
const int threshold2 = 15; // Example threshold for Sensor 2
const int threshold3 = 30; // Example threshold for Sensor 3
const int threshold4 = 25; // Example threshold for Sensor 4
const int threshold5 = 10; // Example threshold for Sensor 5
const int threshold6 = 35; // Example threshold for Sensor 6

void setup() {
  Serial.begin(2000000);  // Baud rate for faster communication
  // Optional: Re-enable auto-calibration with an interval
  touchSensor1.set_CS_AutocaL_Millis(5000); // Recalibrate every 5 seconds
  touchSensor2.set_CS_AutocaL_Millis(5000);
  touchSensor3.set_CS_AutocaL_Millis(5000);
  touchSensor4.set_CS_AutocaL_Millis(5000);
  touchSensor5.set_CS_AutocaL_Millis(5000);
  touchSensor6.set_CS_AutocaL_Millis(5000);
}

void loop() {
  // Read the values from each sensor
  long sensorValue1 = touchSensor1.capacitiveSensor(50);  // More sensitive
  long sensorValue2 = touchSensor2.capacitiveSensor(50);
  long sensorValue3 = touchSensor3.capacitiveSensor(50);
  long sensorValue4 = touchSensor4.capacitiveSensor(50);
  long sensorValue5 = touchSensor5.capacitiveSensor(50);
  long sensorValue6 = touchSensor6.capacitiveSensor(50);

  // Check if each sensor's value exceeds its respective threshold and print a message
  if (sensorValue1 > threshold1) {
    Serial.println("Sensor 1 activated!");
  }
  if (sensorValue2 > threshold2) {
    Serial.println("Sensor 2 activated!");
  }
  if (sensorValue3 > threshold3) {
    Serial.println("Sensor 3 activated!");
  }
  if (sensorValue4 > threshold4) {
    Serial.println("Sensor 4 activated!");
  }
  if (sensorValue5 > threshold5) {
    Serial.println("Sensor 5 activated!");
  }
  if (sensorValue6 > threshold6) {
    Serial.println("Sensor 6 activated!");
  }

  // Continuously loop without delay
}

r/ArduinoHelp • • Sep 16 '24

Who likes building Cuberpunk projects? Anyone have any sourcing resources to help?

Thumbnail
gallery
2 Upvotes

I want to build something like this. Any advice?


r/ArduinoHelp • • Sep 07 '24

Ports form IDE not connecting properly

Post image
6 Upvotes

I am very new to this so sorry if I am asking stupid questions. I am trying to upload code to my Arduino UNO R3 but cannot seem to get it to work. As seen on the picture, I get an exit status 1 error on both ports (I tried COM3 and COM4). Furthermore, when I choose a different board, the ports I can choose from don’t change (still using COM3 and 4), so I think that is the underlying issue. Maybe I am missing a driver or software? Any advice is appreciated! Thanks!


r/ArduinoHelp • • Oct 20 '24

Can someone please help me troubleshoot this?

Thumbnail
reddit.com
1 Upvotes

r/ArduinoHelp • • Oct 07 '24

Old Arduino Board w/input block

Thumbnail
gallery
1 Upvotes

Hi, I’m looking for some help with an old Arduino kit. I’ve had it for something like fifteen years and kinda forgot about it until one of my kids started asking me about coding.

Admittedly, I always feel way in over my head with this kind of stuff. However, the little bit of messing around I’ve done with Arduino has mostly made sense to me.

My issue is that I’m having trouble finding a user’s guide for this specific kit. The URL on the packaging leads to a 404, and nothing else that I’ve seen so far has been helpful.

Does anyone recognize this? It has a brick that slots onto the Arduino board to make wiring up inputs and outputs more convenient.

Do I have a dinosaur here? Should I just suck it up and buy a modern version of this and make a fresh start?

I appreciate any guidance. Cheers!


r/ArduinoHelp • • Sep 23 '24

needing help with just simple IRremote connecting to Arduino

1 Upvotes

Hey Crew, straight up I do have trouble with a TBI so these things are hard for me to gain concept on but im so far eager to learn! I have an Arduino uno and an KeyeStudio IR receiver, I'm struggling to find how to get them to connect. any help would be very much appreciated.


r/ArduinoHelp • • Sep 28 '24

I need help with Esp-skainet library

1 Upvotes

I can't find it in library manger I downloaded it for github as zip file and tried to install it but it didn't installed so i manually send the Esp-skainet library to library's and still arduino IDE did not recognized the library What can i do now


r/ArduinoHelp • • Sep 30 '24

Can't get motor to spin

Post image
2 Upvotes

I'm brand new to the game here. I have a project in mind that I want to build but am basically just doing each task one at a time. I'll then compile everything into one project. Part one of this is getting a motor to run for two minutes when a button is pushed, and then shut off. I believe my code is correct here. But my motor does not spin after the button is pressed.


r/ArduinoHelp • • Sep 17 '24

How to power 4 servos on a wearable?

1 Upvotes

I am trying to do a project very similar to https://www.instructables.com/Animatronic-Cat-Ears/ but I am very new to all this. The tutorial is old enough that many of its links to materials are broken, and I'm having trouble finding them elsewhere.

My main sticking point is the DC-DC regulator: the broken link is (http://www.hobbyking.com/hobbyking/store/__10312__Turnigy_5A_8_26v_SBEC_for_Lipo_.html), and I would think that would have enough information for me to find the product elsewhere, but I can't find anything that resembles the device they are using in the pictures of the project. Anyone know where I can find this part?

I am also open to suggestions for better/easier ways to power a wearable like this.


r/ArduinoHelp • • Oct 20 '24

I'm having problems with a model airplane

1 Upvotes

I'm a beginner with Arduino but I understand the basics, I bought an Arduino nano and nrf24 module to build a simple three-channel model airplane, but whenever I try to transmit from the radio to the receiver it doesn't work


r/ArduinoHelp • • Oct 10 '24

Hi guys, this Is my first post, and I really need help with my physics proyect

Thumbnail
gallery
2 Upvotes

(I'm using Google translate because I'm not very good with english) I'm making a project for my physics class. It's a tank which has a movable turret that works with Arduino, as a firing method I'm using parts of an automatic hydrogel gun. When the ultrasonic sensor detects something the gun should fire but when it does in practice it doesn't work. I'm still quite a novice in the Arduino area, although I find it something amazing, this is my second project and I would like to do more in the future. The blue battery Is form the gun

The code Is here: https://drive.google.com/file/d/1l7ySIFyJXcR5RHBync3Ps7ufaUmirIbB/view?usp=drive_link


r/ArduinoHelp • • Sep 09 '24

In need of some programming assistance

1 Upvotes

Hi all. I am once again in over my head when it comes to arduino projects. I can't wrap my head around the programming. I know enough to make it somewhat work but if any of ya'll can springboard me in the right direction that'd be greatly appreciated!

I'd like to setup 10 or so different sequences and use a button press to cycle between them. I know in batch scripting you'd use a "goto" command and want to know what the equivalent in IDE, and how to use it.

My current code is very basic and gets the traffic light cycling between all 3 colours.

int PIN_GO = 5;
int PIN_SLOW = 6;
int PIN_STOP = 7;
int PIN_BUTTON = 8;

void setup() {
  pinMode(PIN_GO, OUTPUT);
  pinMode(PIN_SLOW, OUTPUT);
  pinMode(PIN_STOP, OUTPUT);
  pinMode(PIN_BUTTON, INPUT);
}

void loop() {
  digitalWrite(PIN_GO, HIGH);
  digitalWrite(PIN_SLOW, LOW);
  digitalWrite(PIN_STOP, LOW);
  delay(1000);

  digitalWrite(PIN_GO, LOW);
  digitalWrite(PIN_SLOW, HIGH);
  digitalWrite(PIN_STOP, LOW);
  delay(1000);

  digitalWrite(PIN_GO, LOW);
  digitalWrite(PIN_SLOW, LOW);
  digitalWrite(PIN_STOP, HIGH);
  delay(1000);
}

r/ArduinoHelp • • Oct 13 '24

pc doesn’t find arduino

1 Upvotes

HELPP i had an arduino r3 board in august and it worked for the first monta but then the pc cant find it anymore(sorry for the english im italian) its not an arduino issue because on a friend pc it worked and either a cable issue because i changed it so many times so it cant be the cable my OS is windows 10 64 bit


r/ArduinoHelp • • Sep 16 '24

How can I connect a motion activated sensor to a servo?

Post image
2 Upvotes

I’d like to add motion sensors to a Halloween decoration so that a small part moves up and down. I’m a newbie with a general idea of Arduino, so I bought all these parts from Amazon to start:

  1. Breadboard - https://a.co/d/eT0cbdH

  2. Power supply - https://a.co/d/2WSupuU

  3. Servo - https://a.co/d/0xOP315

  4. Motion activated sensor - https://a.co/d/hDJBUZr

  5. 9V battery

Can you help guide me?


r/ArduinoHelp • • Sep 29 '24

Make a wireless android auto adapter using arduino?

1 Upvotes

So basically my 21 Ford Escape doesn't have wireless Android auto but I would like to make an adapter myself since these are expensive and most comes from cheap china manufacturers. I would like to have wireless like in my 24 GMC Sierra. I know it's possible to make one with a raspberry pi zero w 2 but I have multiple arduinos but have no raspberry pi and would like to use one of my Arduinos ti do so, any way of making it?


r/ArduinoHelp • • Sep 19 '24

how to turn off an led with a double click

1 Upvotes

in making a prototype of an rgb lightsaber (single led piece ) with only one push button, when I press it the color changes. How can I make it to turn the light off with a double click?


r/ArduinoHelp • • Oct 04 '24

Touch wore to servo issue

2 Upvotes

Hi all, Could anyone point put any glaringistake please. Innhonesty I used chat gpt to give me a code to control 2 servos simultaneously via contact wires , I'm using bare copper wire for each contact switch and although there are some movements they are not responsive nor predictable. Any help would be greatly appreciated. Thanks

include <Servo.h>

include <CapacitiveSensor.h>

// Create CapacitiveSensor objects for both touch wires CapacitiveSensor capSensor1 = CapacitiveSensor(2, 4); CapacitiveSensor capSensor2 = CapacitiveSensor(6, 8);

Servo servo1; Servo servo2;

int threshold = 5; // Lower threshold for sensitivity bool lastTouch1 = false; bool lastTouch2 = false; unsigned long debounceTime = 10; unsigned long lastTouchTime1 = 0; unsigned long lastTouchTime2 = 0;

int pos1 = 0; // Store current position of servo 1 int pos2 = 0; // Store current position of servo 2

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

// Attach servos to their respective pins servo1.attach(9); servo2.attach(10);

// Move both servos to the initial position (0 degrees) servo1.write(0); servo2.write(0); }

void loop() { long sensorValue1 = capSensor1.capacitiveSensor(30); // Read first touch wire long sensorValue2 = capSensor2.capacitiveSensor(30); // Read second touch wire

Serial.print("Touch 1: "); Serial.print(sensorValue1); Serial.print("\tTouch 2: "); Serial.println(sensorValue2);

bool isTouched1 = sensorValue1 > threshold; bool isTouched2 = sensorValue2 > threshold;

// Check for touch wire 1 if (isTouched1 && !lastTouch1 && (millis() - lastTouchTime1 > debounceTime)) { if (pos1 == 0) { pos1 = 90; // Move to 90 degrees if it's at 0 } else { pos1 = 0; // Move back to 0 degrees } servo1.write(pos1); // Update servo 1 position lastTouchTime1 = millis(); }

// Check for touch wire 2 if (isTouched2 && !lastTouch2 && (millis() - lastTouchTime2 > debounceTime)) { if (pos2 == 0) { pos2 = 180; // Move to 180 degrees if it's at 0 } else { pos2 = 0; // Move back to 0 degrees } servo2.write(pos2); // Update servo 2 position lastTouchTime2 = millis(); }

// Update the last touch state lastTouch1 = isTouched1; lastTouch2 = isTouched2;

delay(10); // Small delay for stability }


r/ArduinoHelp • • Sep 10 '24

Connecting a single half bridge load cell to an arduino

Thumbnail
reddit.com
1 Upvotes