Lowering the measuring voltage

I want to read 0-400VAC voltage as 0-5V AC
how should i write the program and I want to measure

Use a transformer ?

If I can make 5=400 with a program I won't be using

Well, I think you have to do some basic engineering how to use an Arduino.

I see I think but I have no time worked a project now

Arduino can only accept to input voltage between GND(0V) and VCC(basically 5V).
So you need to reduce the voltage with an external component, not the program.

And who shall do this job, to design the correct interface between the Arduino and external world?

it will remain in computer environment only as a simulation

And how do you will feed the simulation to do the correct work?

I will reduce it with map and simulate it in proteus

Do it!
Have a nice day and enjoy coding.

I wtrote but I can use else of else if
// we define the ınputs we will use
#define INPUT_CHANNEL_1 A0
#define INPUT_CHANNEL_2 A1
#define INPUT_CHANNEL_3 A2

//we define output(relay) we will use
#define OUTPUT_1 3
#define OUTPUT_2 4
#define OUTPUT_3 5

//operating states of relays
#define ALARM_LEVEL_1 65
#define ALARM_LEVEL_2 220
#define ALARM_LEVEL_3 210

#define VDD_VOLTAGE (float)5.0f // define Float voltage value of VDD
#define ADC_RES (float)1023.0f //define Float Reasulation value of ADC

#define Dig2Voltage(x) (float)((float)x * (VDD_VOLTAGE / ADC_RES)) // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V)
#define voltage

long get_channel_voltage(int channel) {
int portValue = 0;
float Voltage = 0;

switch (channel) {
portValue = analogRead(channel);
portValue = analogRead(channel);
portValue = analogRead(channel);

return map((long)Dig2Voltage(portValue), 0, 5, 0, 400);

void setup()
pinMode(OUTPUT_1, OUTPUT);
pinMode(OUTPUT_2, OUTPUT);
pinMode(OUTPUT_3, OUTPUT);

digitalWrite(OUTPUT_1, LOW);
digitalWrite(OUTPUT_2, LOW);
digitalWrite(OUTPUT_3, HIGH);

void loop()
if (get_channel_voltage(INPUT_CHANNEL_1) > ALARM_LEVEL_1)
digitalWrite(OUTPUT_1, HIGH);
Serial.println("IN1 HIGH VOLTAGE");
else if (get_channel_voltage(INPUT_CHANNEL_1) < ALARM_LEVEL_1)
digitalWrite(OUTPUT_1, LOW);
else if (get_channel_voltage(INPUT_CHANNEL_2) > ALARM_LEVEL_2)
digitalWrite(OUTPUT_2, HIGH);
Serial.println("IN2 HIGH VOLTAGE");
else if (get_channel_voltage(INPUT_CHANNEL_2) < ALARM_LEVEL_2)
digitalWrite(OUTPUT_2, LOW);
else if (get_channel_voltage(INPUT_CHANNEL_3) < ALARM_LEVEL_3)
digitalWrite(OUTPUT_3, LOW);
Serial.println("IN3 LOW VOLTAGE");

else if (get_channel_voltage(INPUT_CHANNEL_3) > ALARM_LEVEL_3)
  digitalWrite(OUTPUT_3, HIGH);


Before lunch time I´ve made a low level flight about your sketch.
My recommendation is to build an object, as called measurmentPoint, containing the I/O pin adresses, alarmLevel, timer etc. as members. A measurement method will use this object to process the outputs.

I fear we have little sympathy for providing overdue entries to college assignments. :grin:

Especially when the description of the assignment is so grossly insufficient.

The style of answers you get will reflect this. :face_with_raised_eyebrow:

All the more so when you ignore the instructions for posting questions.

I don't think that's what you want. I think you want to read 400VAC as 5VDC.

I'm also confused as to your question since you state the project will actually not be built. So what's your problem...?

I will read different voltages from 3 inputs with resistance up to 380V AC, so that the ADC of Arduino will detect it, I wanted to do this with software, not a transformer again.

Different things!

An Arduino will literally explode if you put 380VAC onto it. Even if you transform it down to 5VAC you will likely blow it up. It only accepts DC voltages.

You can't, end of story. There will be hardware involved.

Where do you come from?

Turkey you

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.