Chat freely about anything...

User avatar
By brilliancenp
#80896 Hello all,

First post here and I have been working with ESP01 for about 2 weeks. I have been programming mostly my whole life.

Anyway, I am trying to flesh out a wireless receiver and controller for the atari 2600. I am tired of having to sit close to the TV lol. I know there are solutions out there but I wanted to put my programming into use for something new and have physical form.

I am using an esp01 with a 74hc165 on a breadboard with some buttons to send a byte with bits corresponding to which buttons are pressed to another esp01 with a 74hc595 to take that data and put it out to the console. To test this I have put a led on each pin of the 595 so it will go off when the button is pressed. So far everything is working. I push a button it sends the data to the esp correctly (confirmed in the serial monitor) but the corresponding led doesn't light. I have been fighting this for a bit. In my frustration I loaded up a simple 595 sketch that lights up 8 leds to ensure the 595 was working properly and it is. Using the simple 8 led sketch I started to put things in from the console receiver sketch. I started with the configuration of the WIFI and used the same 8 LED pattern to display while the module WIFI.status() != WL_CONNECTED. Running this shows some sort of interference or maybe too much going on in the ESP. Has anyone seen anything like this before? The pattern is there but you can see some of the leds are skipped .

Code: Select all/*
Adafruit Arduino - Lesson 4. 8 LEDs and a Shift Register
*/
#include <ESP8266WiFi.h>
int latchPin = 3;//12
int clockPin = 2;//11
int dataPin = 0;//14
 
byte leds = 0;
const char* ssid = "ATRECEIVE2600";
const char* pass = "A2600Vin";
IPAddress host(192,168,4,2);

void setup()
{
  pinMode(3, FUNCTION_3);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT); 
  pinMode(clockPin, OUTPUT);
  Serial.begin(9600);
 
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);
}
 
void loop()
{
  if(WiFi.status() != WL_CONNECTED)
  {
    leds = 0;
    updateShiftRegister();
    delay(500);
    for (int i = 0; i < 8; i++)
    {
      bitSet(leds, i);
      updateShiftRegister();
      delay(500);
    }
  }
}
 
void updateShiftRegister()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, leds);
   digitalWrite(latchPin, HIGH);
}


Just wondering if anyone else had seen this. I have not found a whole lot on the esp using wireless and a 595, and im also new and just learning the hardware side of things but Im out of ideas and thought I would ask for some help.

Thanks in advance
User avatar
By brilliancenp
#80912 I did some more research and I'm going to guess it is the delay calls that are messing with everything. I am new to Arduino and didn't realize that delay stops everything. I'm guessing since other things are going on in the modified sketch, where as the original there weren't this could be the issue. I am currently modifiying everything using millis() to check timing delays found in this article, here: https://learn.adafruit.com/multi-tasking-the-arduino-part-1/using-millis-for-timing. If I understand them correctly checking millis() allows the loop method to keep looping freely doing different things at different set intervals. Hopefully frees up the loop. You really have to rethink programs using this method, but hopefully it works.
User avatar
By MasonMiles
#81368 The post about the wifi brings knowledge about technical things. The wifi i use is not working on my pc. I can use it on my cell phone but not on PC system. A brand which i work for sale on leather have mens Coats and Jackets Collection , so for having an online store i use to have such information