This was
The 12th Project
Application - Source Code
After 15+ years of smartphones, you really do take Apps for granted

#include
#include
#include
#include
#include
//#include "doubletest.h"
#include
#include
#include
const char* ssid = "Pixel_7750";
const char* password = "sungicho";
WiFiServer server(80);
String header;
// Variable to store onboard LED state
String picoLEDState = "off";// Current time
unsigned long currentTime = millis();
// Previous time
unsigned long previousTime = 0;
// Define timeout time in milliseconds (example: 2000ms = 2s)
const long timeoutTime = 2000;
///TFT Screen reference - re: TFT Screen and ADA fruit RA8875 driver implementation. //
// https://community.element14.com/challenges-projects/element14-presents/b/blog/posts/how-to-set-up-a-tft-screen-on-arduino-with-the-ra8875
// Load Images:
//https://learn.adafruit.com/adafruit-gfx-graphics-library/loading-images
File file,dir;
char chr;
// put function declarations here:
int led = PIN_LED;
int motorPin = 26;
int ledPIN = 17;
int count = 0;
String phrases [10] = {"TEst this once",
"What is this test?",
"HOW TO TEST?",
"ARDUINO is slowly killing me",
"What is the difference between test and that?",
" ",
" 12",
" asdf;asdf",
" this ",
" whaat?"};
int numberMatch[10] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19};
/********************************************************/
// SD Card Initiliziation
// SD.begin ( CS (Chip Select), MOSI, MISO, SCK)
// Declare these pins first
// int SDCSpin = 0;
// int SDMOSIpin = 0;
// int SDMISOpin = 0;
// int SDSCKpin = 0;
// SD.begin(SDCSpin, SDMOSIpin, SDMISOpin, SDSCKpin);
/////// CODE obsolete - CS Pin = SS Pin is the only one that is changeable. Multiple SPI interfaces can share MOSI, MISO, SCK. ///
//*********************************************************/
/***********SPI VALUE DECLARATIONS - PINS******************/
int SDCSpin = 0;
int TFTCSpin = 0;
int MISOpin = 0;
int MOSIpin = 0;
int SCKpin = 0;
#define RA8875_INT 3
#define RA8875_CS 10
#define RA8875_RESET 9
Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
uint16_t tx, ty;
double voidnumber = 0;
//******************** SETUP Loop ************************//
void setup() {
// put your setup code here, to run once:
pinMode(LED_BUILTIN, OUTPUT);
pinMode(ledPIN, OUTPUT);
Serial.begin (9600);
pinMode(motorPin, OUTPUT);
// ---- Wifi --- //
Serial.println("Wifi Setting up");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid,password);
while (WiFi.status() != WL_CONNECTED){
delay(500);
Serial.print(".");
delay(500);
}
//Wifi setup complete:
Serial.println("");
Serial.print("PICO CONNECTED TO WIFI NETWORK!");
Serial.println(WiFi.SSID());
Serial.print("Assigned IP Address: ");
Serial.println(WiFi.localIP());
Serial.println("Moving to main program");
delay(10000);
//---------- SERVER -----------//
server.begin();
// Serial.println("RA8875 start");
// /* Initialize the display using 'RA8875_480x80', 'RA8875_480x128', 'RA8875_480x272' or 'RA8875_800x480' */
// if (!tft.begin(RA8875_480x272)) {
// Serial.println("RA8875 Not Found!");
// while (1);
// }
// Serial.println("Found RA8875");
// tft.displayOn(true);
// tft.GPIOX(true); // Enable TFT - display enable tied to GPIOX
// tft.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
// tft.PWM1out(255);
// // With hardware accelleration this is instant
// tft.fillScreen(RA8875_WHITE);
// // Play with PWM
// for (uint8_t i=255; i!=0; i-=5 )
// {
// tft.PWM1out(i);
// delay(10);
// }
// for (uint8_t i=0; i!=255; i+=5 )
// {
// tft.PWM1out(i);
// delay(10);
// }
// tft.PWM1out(255);
// tft.fillScreen(RA8875_RED);
// delay(500);
// tft.fillScreen(RA8875_YELLOW);
// delay(500);
// tft.fillScreen(RA8875_GREEN);
// delay(500);
// tft.fillScreen(RA8875_CYAN);
// delay(500);
// tft.fillScreen(RA8875_MAGENTA);
// delay(500);
// tft.fillScreen(RA8875_BLACK);
// // Try some GFX acceleration!
// tft.drawCircle(100, 100, 50, RA8875_BLACK);
// tft.fillCircle(100, 100, 49, RA8875_GREEN);
// tft.fillRect(11, 11, 398, 198, RA8875_BLUE);
// tft.drawRect(10, 10, 400, 200, RA8875_GREEN);
// tft.fillRoundRect(200, 10, 200, 100, 10, RA8875_RED);
// tft.drawPixel(10,10,RA8875_BLACK);
// tft.drawPixel(11,11,RA8875_BLACK);
// tft.drawLine(10, 10, 200, 100, RA8875_RED);
// tft.drawTriangle(200, 15, 250, 100, 150, 125, RA8875_BLACK);
// tft.fillTriangle(200, 16, 249, 99, 151, 124, RA8875_YELLOW);
// tft.drawEllipse(300, 100, 100, 40, RA8875_BLACK);
// tft.fillEllipse(300, 100, 98, 38, RA8875_GREEN);
// // Argument 5 (curvePart) is a 2-bit value to control each corner (select 0, 1, 2, or 3)
// tft.drawCurve(50, 100, 80, 40, 2, RA8875_BLACK);
// tft.fillCurve(50, 100, 78, 38, 2, RA8875_WHITE);
// pinMode(RA8875_INT, INPUT);
// digitalWrite(RA8875_INT, HIGH);
// tft.touchEnable(true);
// Serial.print("Status: "); Serial.println(tft.readStatus(), HEX);
// Serial.println("Waiting for touch events ...");
}
void loop() {
// ----------WIFI Client Setup --------------//
WiFiClient client = server.available();
if (client) { // If a new client connects,
currentTime = millis();
previousTime = currentTime;
Serial.println("New Client."); // print a message out in the serial port
String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected() && currentTime - previousTime <= timeoutTime) { // loop while the client's connected
currentTime = millis();
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
header += c;
if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
// Switch the LED on and off
if (header.indexOf("GET /led/on") >= 0) {
Serial.println("LED on");
picoLEDState = "on";
digitalWrite(LED_BUILTIN, HIGH);
} else if (header.indexOf("GET /led/off") >= 0) {
Serial.println("LED off");
picoLEDState = "off";
digitalWrite(LED_BUILTIN, LOW);
}
// Display the HTML web page
client.println("");
client.println("");
client.println("");
// CSS to style the on/off buttons
client.println("");
// Web Page Heading
client.println("Pico W LED Control
");
// Display current state, and ON/OFF buttons for Onboard LED
client.println("Onboard LED is " + picoLEDState + "
");
// Set buttons
if (picoLEDState == "off") {
//picoLEDState is off, display the ON button
client.println("");
} else {
//picoLEDState is on, display the OFF button
client.println("");
}
String countstr = String(count);
client.println(""+countstr+"
");
delay(200);
client.println("");
client.println("");
// The HTTP response ends with another blank line
client.println();
// Break out of the while loop
break;
} else { // if you got a newline, then clear currentLine
currentLine = "";
}
} else if (c != '\r') { // if you got anything else but a carriage return character,
currentLine += c; // add it to the end of the currentLine
}
}
}
// Clear the header variable
header = "";
// Close the connection
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
Serial.println("NEW RUN TIME : "+ count);
count++;
if (count>100){
count =0;
}
delay(20);
// Serial.println("Test");
// Serial.print(count);
// String textthis = "Count is at: ";
// //voidnumber = int(doublethis(count));
// //Serial.print(textthis + voidnumber);
// Serial.println(phrases[count]);
// // float xScale = 1024.0F/tft.width();
// // float yScale = 1024.0F/tft.height();
// digitalWrite(LED_BUILTIN, HIGH);
// digitalWrite(motorPin, HIGH);
// digitalWrite(ledPIN, HIGH);
// delay(200);
// digitalWrite(LED_BUILTIN, LOW);
// digitalWrite(motorPin, LOW);
// digitalWrite(ledPIN, LOW);
// delay(200);
// // SerialUSB.begin(0); // start USB
// // while (!SerialUSB) {;}; // wait for USB to start
// // SD.begin(15); // start SD with SS on A15
// // file = SD.open("hello.txt",FILE_WRITE); // open file for writing
// // file.println(phrases[count]); // write to file
// // file.close(); // close file
// // dir = SD.open("/"); // open root directory
// // file = dir.openNextFile(); // open first file
// // SerialUSB.print("reading ");
// // SerialUSB.print(file.name()); // get file name
// // SerialUSB.println(":");
// // while (file.available()) // loop over file
// // SerialUSB.write(file.read()); // print contents
// count++;
// if (count > 10){
// count =0;
// }
}
- © Untitled
- Design: HTML5 UP