arduino 2x motor control and 4 relays

i want to use arduino uno
and send 2 pwm signals (have read pin 5 and 6 are pwm signal 1khz)
and for the relay i can use pin 3, 9,10 and 11

i want to use the analogpin a0-a5
2 i wil use a potionmeter
and the orther 4 i use a push-to-make button (or a switch)

the aboven is progject 1.0
and for project 2.0 i like to wright a program that can give a pwm signal that goes change in duty
up and down, swipe between 80% and 60% back to 80% for example

i have 1 board whit 4 relays, on it, and 2x ims-1 motor driver
i know that i need for ims-1 a extra pin to enable the unit. but there fore i use a relay to do this,

and for the relay i can use pin 3, 9,10 and 11

PWMing a relay does not make sense. What it the relay controlling? Is it a mechanical relay?

i want to use the analogpin a0-a5

For? What is the problem?

Why use an analog pin to read a digital switch?

the red led are going to a relay
and the blue led are going to pwm input
for the relay it on and off enough
for the orther i need a pwm signal

if you look to the code, it is more red and full whit errors than that it works
i am thinking to wright the code for every switch and test it, after that i can put 6 of the codes together

@pauls
no that is correct pwmign a relay does not make sense, thought it can also give on and off signal
but if that is not than i need to use 2,4,7 and 8
relay board

i need to use 2 analogpin for controlling the pwm output.
thought i can also use this for the relay, or is thit not possible??

Your switch wiring is wrong. You would need pull down resistors on A0-A3 to make that work. You get errors because you specified analog pins in lower case, like "a1".

const int pin0 = a0;

i wanted to use it but is say error on void setup

but i can't find anything wrong whit the code.

if this works i make one whit push button to control it.
after that i wil try to get everything work in one code

i wanted to use it but is say error on void set...but i can't find anything wrong whit the code.

Couldn't be bothered posting YOUR code, either, I see.

My code is in the link.
But i have made a screenshot of it.
Because i am on a cellphone, at this moment.

got pwm part to work (atleast on the pc)

int motor = 9;
int motor1 = 10;
int potentionmeter = A5;
int potentionmeter1 = A4;
int value;
int value1;
int motor_speed;
int motor_speed1;

  
void setup()

{
  pinMode(motor, OUTPUT);
  pinMode(motor1, OUTPUT);
  pinMode(potentionmeter, INPUT);
  pinMode(potentionmeter1, INPUT);
}

void loop()

{
  value = analogRead(potentionmeter);
  motor_speed = map(value,0,1023,1,254);
  analogWrite(motor,motor_speed);

  
  value1 = analogRead(potentionmeter1);
  motor_speed1 = map(value1,0,1023,10,240);
  analogWrite(motor1,motor_speed1);

}

on the aboven link you can see it works, in real life the pwm signal goes to ims-1 motordriver

next part is the relay function
but again void setup does again give errors. but why i don't know

int schak = 3;
int relay = 8;

void setup
{
  pinMode(schak, INPUT);
  pinMode(relay, OUTPUT);
}
void loop
{
  value = analogRead(schak);
  schaki = map(value,0,1023,10,240);
  if (schaki>500) analogWrite(relay, HIGH);
  else (relay, LOW);
}

error code
4:6: error: variable or field 'setup' declared void
6:24: error: expected '}' before ';' token
7:10: error: expected constructor, destructor, or type conversion before '(' token
8:1: error: expected declaration before '}' token

  if (schaki>500) analogWrite(relay, HIGH);
  else (relay, LOW);

Needs more work.

Please use code tags when posting code.

i know it needs more work
but i get already a error on void setup part
so i can't test it and see where the rest of the code does not function
i wanted to post the code in code tag, but didn't find it
but after looking again found it

int schak = 3;
int relay = 8;

void setup
{
  pinMode(schak, INPUT);
  pinMode(relay, OUTPUT);
}
void loop
{
  value = analogRead(schak);
  schaki = map(value,0,1023,10,240);
  if (schaki>500) analogWrite(relay, HIGH);
  else (relay, LOW);
}

in arduino pasting the code and get

sketch_jan02a:4: error: function definition does not declare parameters
sketch_jan02a:9: error: function definition does not declare parameters

that is only on void setup
is a reason for this

if (schaki>500) analogWrite(relay, HIGH);
  else (relay, LOW);

Still needs more work.

As does this void setup (hint: it doesn't look like any other code you've seen that does compile)

(I don't understand why you'd want to do an analogWrite to a relay if the condition is true, and I can't figure what the else clause is doing)

stupid me, after placing () to it works,
but funny i have that tried before and at that moment it does not worked.
mayby a bug in 123d.cicruit.io

but now indeed the rest of the code
is there a big diffrent in analogWrite and digitalWrite

int schak = A3;
int relay = 8;
int value;
int schaki;

void setup()
{
  pinMode(schak, INPUT);
  pinMode(relay, OUTPUT);
	Serial.begin(9600);
}
void loop()
{
  value = analogRead(schak);
  schaki = map(value,0,1023,10,240);
  if (schaki>220) digitalWrite(relay, HIGH);
  else digitalWrite(relay, LOW);
  Serial.print(schaki);


}

i can now control the relay on and off in this simulation
only i want to make it to hold the setting
and only change if you press again

only i want to make it to hold the setting

You want what to hold what setting?

and only change if you press again

If you press what again?

Details matter!

i have found the code where i whas looking for

int inPin = A3;         // the number of the input pin
int outPin = 8;       // the number of the output pin

int state = HIGH;      // the current state of the output pin
int reading;           // the current reading from the input pin
int previous = LOW;    // the previous reading from the input pin

// the follow variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long time = 0;         // the last time the output pin was toggled
long debounce = 200;   // the debounce time, increase if the output flickers

void setup()
{
  pinMode(inPin, INPUT);
  pinMode(outPin, OUTPUT);
}

void loop()
{
  reading = digitalRead(inPin);

  // if the input just went from LOW and HIGH and we've waited long enough
  // to ignore any noise on the circuit, toggle the output pin and remember
  // the time
  if (reading == HIGH && previous == LOW && millis() - time > debounce) {
    if (state == HIGH)
      state = LOW;
    else
      state = HIGH;

    time = millis();    
  }

  digitalWrite(outPin, state);

  previous = reading;
}

whit this i can set the relay on and pressing again set it to off

in the link it works on the simulator

need only to wright it for the orther 3 switches, after that i need to get everything in one code.

for the real live situation
i need a resistor on the switch side to gnd.
on the output goes to a relay board and to ims-1 motordriver, i believe i don't need to put resistors on it, becasue on that board is already done that.