Hello guys
I'm trying to get a drop down menu to select hour and minute values and store it for an int, but idk how do I do this.
I'm using a UNO board, a HanRun HR911105A and a TinyRTC I2C Module
If anyone can help me, I'm glad!
Hello guys
I'm trying to get a drop down menu to select hour and minute values and store it for an int, but idk how do I do this.
I'm using a UNO board, a HanRun HR911105A and a TinyRTC I2C Module
If anyone can help me, I'm glad!
The usual response is to ask for you to post the you have so far, accompanied by a meaningful schematic of what/how your components are connected together.
Give it a shot... it won’t be the last time!
Hello! I'm sorry for the delay... I'm traveled this weekend and returned now
Btw, I don't have any code for those functions. I have two different codes, but I have an issue:
In this code:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 195 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port
String readString;
void setup() {
pinMode(4, OUTPUT); //Relay pin
digitalWrite(4, HIGH);
//start Ethernet
Ethernet.begin(mac, ip, gateway, gateway, subnet);
server.begin();
//enable serial data print
Serial.begin(9600);
}
void loop() {
// Create a client connection
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
//read char by char HTTP request
if (readString.length() < 100) {
//store characters to string
readString += c;
//Serial.print(c);
}
//if HTTP request has ended
if (c == '\n') {
///////////////
Serial.println(readString);
//now output HTML data header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<HTML>");
client.println("<HEAD>");
client.println("<TITLE>Arduino GET test page</TITLE>");
client.println("</HEAD>");
client.println("<BODY>");
client.println("<H1>HTML form GET example</H1>");
client.println("<FORM ACTION='/' method=get >");
client.println("Pin 4 'on' or 'off': <INPUT TYPE=TEXT NAME='LED' VALUE='' SIZE='25' MAXLENGTH='50'>
");
client.println("<INPUT TYPE=SUBMIT NAME='submit' VALUE='Change Pin 4!'>");
client.println("</FORM>");
client.println("
");
client.println("</BODY>");
client.println("</HTML>");
delay(1);
//stopping client
client.stop();
/////////////////////
if (readString.indexOf("on") > 0) //checks for on
{
digitalWrite(4, LOW); // set pin 4 high
Serial.println("Led On");
}
if (readString.indexOf("off") > 0) //checks for off
{
digitalWrite(4, HIGH); // set pin 4 low
Serial.println("Led Off");
}
//clearing string for next read
readString = "";
}
}
}
}
}
I have a textbox and two commands: on and off.
And in this code
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
int Relay = 8;
byte OnHour = 0;
byte OnMinute = 6;
byte OffHour = 0;
byte OffMinute = 8;
void setup () {
Serial.begin(9600);
pinMode(Relay, OUTPUT);
digitalWrite(Relay, HIGH);
Wire.begin();
RTC.begin();
// Check to see if the RTC is keeping time. If it is, load the time from your computer.
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// This will reflect the time that your sketch was compiled
RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop () {
DateTime now = RTC.now();
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.year(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
delay(1000);
if (now.hour() == OnHour && now.minute() == OnMinute) {
digitalWrite(Relay, LOW);
}
else if (now.hour() == OffHour && now.minute() == OffMinute) {
digitalWrite(Relay, HIGH);
}
}
I have an RTC to activate a relay.
I need a textbox to select a hour value and other to minutes and store it in an int, but I'm stuck on this...
My wiring diagram:
So you are trying to use an HTML page (with dropdowns).. to set the time on the RTC?
Is that the heart of this project? I'm not clear.
You have:
UNO
RTC
Ethernet shield...
is this correct?
I can see the problem...
You have two very simple code examples that probably work by themselves, however what you’re looking for is one fairly complex sketch to do something completely different.
Step one, forget the RTC, develop a web page sketch that creates a single drop-down control, then learn how to populate and process that.
Step two, extend that so you have multiple drop downs for all the variables you need.... day,month, year, hour, minute, second etc.
Once you have those working (no RTC),....
Step three, push those variables in to ‘set’ the rtc,
You may like to use the current rtc vale’s to initialise the dropdown in step one.
This set of tasks will take a capable beginner a couple of days of concentrated work, but you’ll learn a lot.
Forget the rest of your project for now.
This will keep you busy as you develop the code and function()s needed to be reliable and consistent.
Additionally.. in my footer (I think, but for sure posted on the site) are a bunch of links that use webpages to communicate..
** Disclaimer: Some/most use PHP scripts to save to database..etc.. and do other serverside work... you can ignore all that, the same HTML interface/code will be the same.