@SteveThackery Thank you for your kind words. You're right, I am running out of time and patience, but I truely, truely appreciate your kind words. It means a lot to me to have people willing to help me, so thank you all.
As I mentioned before, I don't know how to read/draw schematics, and I don't have time to learn, however, I can provide an image of my wiring.
And code:
// include the library code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// include neopixel library
#include <Adafruit_NeoPixel.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
int pressurePin1 = A0;
int forceA;
int pressurePin2 = A1;
int forceB;
int DCMotor = 9;
//Led Strip constraints
const int dinPin = 6; // Din pin to Arduino pin 6
const int numOfLeds = 4; // Number of leds
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(numOfLeds, dinPin, NEO_GRB + NEO_KHZ800);
// Colour LED pixels
int red = 0; //Value from 0(led-off) to 255().
int green = 255;
int blue = 0;
#define pwm 3 //NEW STUFF
// #define pot1 A0 //NEW STUFF
// #define pot2 A1 //NEW STUFF
void setup() {
pinMode(pwm, OUTPUT); //NEW STUFF
//pinMode(pot1,INPUT); // NEW STUFF
//pinMode (pot2, INPUT); //NEW STUFF
Serial.begin (9600);
pinMode (DCMotor, OUTPUT);
pixels.begin(); // Initializes the NeoPixel library
pixels.setBrightness(100); // Value from 0 to 100%
// set up the LCD's number of columns and rows:
lcd.begin();
// Print a message to the LCD.
lcd.print ("Initialising...");
delay (1000);
lcd.clear ();
delay (1000);
lcd.print(" Safety Wheel ");
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
lcd.print (" Arya Nayak ");
delay (5000);
lcd.clear ();
lcd.print (" Engine Speed");
lcd.setCursor(0, 1);
lcd.print ("100%");
analogWrite (DCMotor, 255);
}
void loop () {
forceA = analogRead(pressurePin1);
forceB = analogRead(pressurePin2);
Serial.println(forceA);
Serial.println(forceB);
float val = analogRead(pressurePin1);//NEW STUFF
float duty = map(val, 0, 1023, 0, 255); //NEW STUFF
analogWrite(pressurePin1, duty); //here's how to generate PWM signal from Digital arduino pin NEW STUFF
Serial.println(duty);// NEW STUFF
float val2 = analogRead(pressurePin2);//NEW STUFF
float duty2 = map(val2, 0, 1023, 0, 255); //NEW STUFF
analogWrite(pressurePin2, duty2); //here's how to generate PWM signal from Digital arduino pin NEW STUFF
Serial.println(duty2);// NEW STUFF
if (forceA < 500) {
lcd.clear ();
lcd.print (" Engine Speed");
lcd.setCursor (0, 1);
lcd.print ("50%");
analogWrite (DCMotor, 255); // 128
for (int i = 0; i < numOfLeds; i++) {
pixels.setPixelColor(i, pixels.Color(red, green, blue));
pixels.show(); // This sends the updated pixel color to the hardware.
delay(200); // Delay for a period of time to change the next led
pixels.clear ();
delay (200);
delay (100);
}
}
else if (forceB < 500) {
lcd.clear ();
lcd.print (" Engine Speed");
lcd.setCursor (0, 1);
lcd.print ("50%");
analogWrite (DCMotor, 255); // 128
for (int i = 0; i < numOfLeds; i++) {
pixels.setPixelColor(i, pixels.Color(red, green, blue));
pixels.show(); // This sends the updated pixel color to the hardware.
delay(200); // Delay for a period of time to change the next led
pixels.clear ();
delay (200);
delay (100);
}
}
else {
analogWrite (DCMotor, 128);// 255
lcd.clear ();
lcd.print (" Engine Speed");
lcd.setCursor (0, 1);
lcd.print ("100%");
for (int i = 0; i < numOfLeds; i++) {
pixels.clear ();
delay (200);
}
}
delay (4500) ;
}
Hope this helps.
Thanks.