I want this code:
#define pwmPin 11
void setup()
{
analogWrite(pwmPin, 0);
}
void loop()
{
long t = millis();
float tt = 2.0 * M_PI * t / 1000.0;
float fm = sin(tt/500.0);
float ttt = tt + 400*fm;
float v = sin(ttt);
float am = sin(ttt/12.0);
v = v * ((am + 1.0) / 2);
int vv = round(127.0 * v + 50);
if (vv < 30)
vv = 0;
analogWrite(pwmPin, vv);
}
Embedded in another program that will run this code for 20 minutes, stop it for 15 minutes, set to loop infinitely. Can this be done and how much will it cost?
Thanks and have a great day!
Hi,
I believe you want to have this function inside another main function that will execute this code for 20 mins and stop (pause) for 15 mins and then again run for 20 mins...pause for 15 min... We can do that. With out RTC, approximate timing can be achieved.
Thanks!
I will posted this code to your inbox soon..
Easy task pay me when you have tested the code and made sure it does what you want.
Cheers Pete.
Edit .... I could not send you a MP so here is the code
You will need to set the pwnPin yourself to suite your hardware
#include <Time.h>
#define OnTime (now() + (20 * 60))
#define OffTime (now() + (15 * 60))
#define pwmPin 5
boolean PWMon = true;
time_t NextSwitch;
void setup()
{
analogWrite(pwmPin, 0);
NextSwitch = OnTime;
}
void loop()
{
if(now() >= NextSwitch)
{
PWMon = !PWMon;
if (PWMon)
{
NextSwitch = OnTime;
}
else
{
NextSwitch = OffTime;
}
}
if (PWMon) RunLoop();
}
void RunLoop()
{
long t = millis();
float tt = 2.0 * M_PI * t / 1000.0;
float fm = sin(tt/500.0);
float ttt = tt + 400*fm;
float v = sin(ttt);
float am = sin(ttt/12.0);
v = v * ((am + 1.0) / 2);
int vv = round(127.0 * v + 50);
if (vv < 30)
vv = 0;
analogWrite(pwmPin, vv);
}
Hey,
Do not award me the project, I just want to know what are you trying to do with the script. It looks quite strange, maybe if you explain to me the process step by step I can build you a new one in 30 mins
Hello,
Do you want new code to be developed for arduino Uno? Do you have other code into which this code needs to be merged?
Kindly provide further details so that I can analyze it further and we get started on it quickly.
Best Regards,
Polestar
Hi,
Yes it can be done quite easilly.
I ve already written the code you need to execute (i used one timer)
contact me back if interested.
code is commented so it's easy to understand.
Cheers
can be done.
Do you want precise timing? I mean i can interface date time module if you want precise timing.
Please let me know more information about your requirement.
Hope to hear from you soon.
Thank you,
Ruwan.
I have many years of experience with Arduino Uno and similar boards. I have worked with simple code to more complex which involved SD and Ethernet integration.