Spot Welder Timing Module

Just fyi I am still kinda new to arduino so don't judge. Im a trying to create a timing module where if i turn a potentiometer it will turn a relay on for more or less depending on how far it is turned. I am using a relay shield, which you can active the relay 1 via pin 7, and im a reading the pot with analog 0.

Here is what I have... Right now the relay is not turning on no matter where the pot is turned and the shield displays a dim light where it indicates if the relay is on. Please Help!

int relay = 7;
 void setup() {
  // put your setup code here, to run once:
pinMode(relay, OUTPUT);
pinMode(A0, INPUT);

void loop() {
  // put your main code here, to run repeatedly:
int sensorValue = analogRead(A0);
int mapped = map(sensorValue,0,1023,0.1,1); 
digitalWrite(relay, HIGH);
digitalWrite(relay, LOW);


The relay is an electromechanical and magnetic component, it needs a large time to dock, try replacing its time interval value with a larger value, then you can prove that.

If you need a shorter switching time, then I suggest you search for MOSFET. And also by an optocoupler driver for MOSFET, maybe hcpl3120.

int mapped = map(sensorValue,0,1023,0.1,1);

0.1 is not an integer. map() only works with integers.

You are turning the relay on for (mostly) zero milliseconds, sometimes 1 ms at the extreme limit of adjustment. Then off for 10ms. No wonder the indicator is rather dim.

Ok great thanks I will fix that