sorta works

This commit is contained in:
equant 2021-06-30 18:29:27 -07:00
parent 18e0156328
commit d4a0a29c43

View File

@ -1,29 +1,28 @@
/*********
Rui Santos
Complete project details at http://randomnerdtutorials.com
*********/
/*
*/
// Load Wi-Fi library
#include <WiFi.h>
// Replace with your network credentials
const char* ssid = "GSO";
const char* password = "xerxes27";
// Set web server port number to 80
WiFiServer server(80);
// Variable to store the HTTP request
String http_header;
/* OUTPUTS (numbers mean GPIO port) */
#define DATA_0_PIN 9
#define DATA_1_PIN 10
#define DATA_2_PIN 5
#define DATA_3_PIN 5
#define DATA_4_PIN 5
#define DATA_5_PIN 5
#define DATA_6_PIN 5
#define DATA_7_PIN 5
#define DATA_0_PIN 18
#define DATA_1_PIN 19
#define DATA_2_PIN 23
#define DATA_3_PIN 25
#define DATA_4_PIN 26
#define DATA_5_PIN 27
#define DATA_6_PIN 32
#define DATA_7_PIN 33
#define DEVSEL_PIN 5
#define DEVSEL_PIN 35
#define ONBOARD_LED 2
// Auxiliar variables to store the current output state
String output26State = "off";
@ -33,6 +32,8 @@ String output27State = "off";
const int output26 = 26;
const int output27 = 27;
unsigned char data_register = 0;
// Current time
unsigned long currentTime = millis();
// Previous time
@ -44,10 +45,10 @@ void setup() {
Serial.begin(115200);
//Serial.begin(9600);
// Initialize the output variables as outputs
//pinMode(output26, OUTPUT);
pinMode(ONBOARD_LED, OUTPUT);
//pinMode(output27, OUTPUT);
// Set outputs to LOW
//digitalWrite(output26, LOW);
digitalWrite(ONBOARD_LED, LOW);
//digitalWrite(output27, LOW);
pinMode(DATA_0_PIN, INPUT);
pinMode(DATA_1_PIN, INPUT);
@ -135,7 +136,7 @@ void http_check() {
// Display current state, and ON/OFF buttons for GPIO 26
client.println("<p>GPIO 26 - State " + output26State + "</p>");
// If the output26State is off, it displays the ON button
if (output26State=="off") {
if (output26State == "off") {
client.println("<p><a href=\"/26/on\"><button class=\"button\">ON</button></a></p>");
} else {
client.println("<p><a href=\"/26/off\"><button class=\"button button2\">OFF</button></a></p>");
@ -144,7 +145,7 @@ void http_check() {
// Display current state, and ON/OFF buttons for GPIO 27
client.println("<p>GPIO 27 - State " + output27State + "</p>");
// If the output27State is off, it displays the ON button
if (output27State=="off") {
if (output27State == "off") {
client.println("<p><a href=\"/27/on\"><button class=\"button\">ON</button></a></p>");
} else {
client.println("<p><a href=\"/27/off\"><button class=\"button button2\">OFF</button></a></p>");
@ -197,7 +198,12 @@ unsigned char copy_DATA_pins_to_register(void) {
void loop() {
//http_check()
if (digitalRead(DEVSEL_PIN) == LOW) {
data_register = copy_DATA_pins_to_register()
//Serial.println(copy_DATA_pins_to_register());
digitalWrite(ONBOARD_LED,HIGH);
data_register = copy_DATA_pins_to_register();
Serial.print("[");
Serial.print(data_register);
Serial.println("]");
} else {
digitalWrite(ONBOARD_LED,HIGH);
}
}