Uno wifi r3 digital pins dont work

Hi, I'm quite new in Arduino and I try to make output from any of the digital pins in my uno wifi r3 but any my assignment just doesn't work. I have tried to use pin number according to the pinout diagram, but nothing work, however d1 wemos mini works really good if I use "D" prefix indetifier for the desiring pin number, unfortunately I need VIN which is not present on d1 wemos mini. The sketch itself works as I expecting so only digital pins look not working for me. Can somebody help me please?

Welcome to the Forum!
You will get faster and better help if you post the code as requested by the forum guidelines. Read the forum guidelines to see how to properly post code and some good information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Providing wiring diagram of your connections also will help.

const int MOSFSWITCH = D5; //for uno wifi r3 I use just 5
int statusMOSFSWITCH = HIGH;

//some code here

//this func set some flag to false and make digitalWrite to the pin output
void handleMosfswitchOn() {
  rndLoopFlag = false;
  
  statusMOSFSWITCH = HIGH; // conditions to make the Mosfet turn on
  digitalWrite(MOSFSWITCH, statusMOSFSWITCH);
  Serial.println("ON");
  response();
}

void handleMosfswitchOff() {
  rndLoopFlag = false;
  
  statusMOSFSWITCH = LOW; // conditions to make the Mosfet turn off
  digitalWrite(MOSFSWITCH, statusMOSFSWITCH);
  Serial.println("OFF");
  response();
}

//some code here

void setup() {
    Serial.begin(9600);
    delay(1000); 
    WiFi.softAP(ssid, password); 
    IPAddress apip = WiFi.softAPIP();     
    server.on("/", response); 
    server.on("/MOSFSWITCHOff", handleMosfswitchOff);
    server.on("/MOSFSWITCHOn", handleMosfswitchOn); 
    server.on("/MOSFSWITCHRnd", handleMosfswitchRnd);
    server.on("/MOSFSWITCHRnd2", handleMosfswitchRnd2);
    server.begin();    
    pinMode(MOSFSWITCH, OUTPUT);
    digitalWrite(MOSFSWITCH, statusMOSFSWITCH);
}

void loop() {
    server.handleClient();
    
    if(rndLoopFlag) {
      rndLoop(timeWork);
    }
}

Sorry, but that schematic will just not do. Please draw a proper one using pen and paper. It is just not clear how things are actually connected, that is the whole point of a schematic.

For example, I see a plug with 4 terminals, and 2 connections. No idea what goes to what.

To my knowledge there is no uno wifi r3. There is an uno wifi and an uno wifi rev2.

Please provide a link to the exact board that you have

schematic works perfectly with any controller as I expecting, I presume the issue with the pin assignment or with uno wifi r3 board 99%

Why do you need Vin?

Schematics don't "work", circuits do. Your drawing is practically useless for the purpose of communicating your circuit with other people. Please fix it.

Please read the forum guidelines again to understand, why we need exactly your schematic and not the "similar" or "something like"...

Why do I need VIN? because I don't want to use battery of course and recharge It from time to time, but actually I try to figure out why I cannot use r3 uno wifi first..

Your board contains two mcu. On the pins of which of the two controllers you are trying to output a signal and in which of the chips you are flashing the program?

it explains nothing

1 Like

That's a good question. How to determine which one I'm flashing? Ok, can I rephrase my main question?! How I can be sure that I assign pin numbers right? For this porpuse I assume schematic, circuit are not important..

In the middle of the board you can see the group of switches. Use it to control which mcu is connected to PC right now.
In general, in my humble opinion, Uno Wifi is nightmare. Using two separate boards - normal Uno and Esp8266 - much easier and more convenient

Ok, according to the guides from public sources I upload the code using 5-7 ON, so launch the board using 1-4 ON, the rest is OFF.

with R3 it looks like this. In short words the sketch just switchs the mosfet. Switch button is using for manual switching, It's not reflecting in the code of the sketch.

Your mosfet is connected to pin, which belongs to the atmega328 mcu, but your code is obviously for ESP8266.
So it's hardly surprising that the pin doesn't work

You assume incorrectly.

If you can't draw a schematic then how on earth are you going to make anything. That picture is not a schematic, if you think it is then the project you are trying to do is beyond you at this point in your learning. Go back and do some more reading and exploring the examples in the IDE.

1 Like

Wait, this code works in wemos D1 so I just need to adapt It to R3. I thought I just need to set correct pin number. If I need to do something else that's great, but there is no any source I have red about difference between ESP9266 and atmega328 mcu in terms of code except pin assignment. So in other words my task should be very simple...

Then read a bit more please.

Did you understand me? You connected the mosfet to a pin on one MCU, but upload the program to another.
And you expect it to work? Really?