Turning pc on with 12 led trigger

Wolframore

Joined Jan 21, 2019
2,619
You can send a sleep command that involves programming Win32C++. Would be easier to do a hardware splice into a sleep button if you have that on you computer. I believe another solution is to turn your Arduino into a keyboard on the I2C bus but again it would involve programming.
 

Thread Starter

Bigfillly

Joined Jan 4, 2019
73
Whow that’s way to advance for me, I tried to do my own programming last time I used it but I failed,
I’m getting there now, I’ve just thrown together a very basic ldr with a potentiometer on a breadboard, I’ll try the arduino with a relay tomorrow,
I’m getting there, thanks to all your guidance :-D
 

Tonyr1084

Joined Sep 24, 2015
9,744
For what it's worth, here's my opinion: I'd use two sensors to detect when the sun is in certain positions. (and someone just added their comment) The illustration below shows two sensors pointed in the direction of sunrise and sunset. MY thinking is that from what you described you want a pulse in the morning and a pulse in the evening. Using a solar panel would give you an ever increasing energy level as the sun rose and flew through the day, then decrease as the sun sets. It would take programming to sense the levels and use that as a trigger. The system I've come up with has a spike in the output from one sensor then both sensors not being directed at the sun continue to maintain a low level output. LET ME SAY: I'm not sure how LDR's work, only that light levels change their resistance. The comparator might be backwards. Nevertheless, when the input at the comparator is higher (or lower) than the reference it can put out a high to a 555 one shot circuit. I'd have to look up how to build one. But the reason for the one shot is because you probably want anywhere from 2 to 5 seconds of output to activate your computer. Thus, in the morning the computer is started. Then in the evening, the same button (the start stop button on the computer) will once again activate for 2 to 5 seconds and send the computer into sleep mode, thus shutting off your mining rig. To be honest, I'm not 100% sure exactly what you're doing, but that doesn't matter. I think this solution will work pretty well. At least this would probably be my first experiment in solving your problem.

Z Solar Sensor.png
 

Tonyr1084

Joined Sep 24, 2015
9,744
Construction of the light choke tubes can either be a pipe with a couple washers inserted, one at the opening facing the target (the sun), a second midway down the tube so that only when light enters directly through the two holes it passes through while almost all other light is blocked. The third choke reduces reflected light that may reflect off the inside of the tube and present a false signal.

I used such a choke tube to help align a photo transistor upon a specific target and eliminate all other extemporaneous light sources. I was able to detect light at 30 yards while rejecting any and all other sources of light.
 

Reloadron

Joined Jan 15, 2015
7,891
There is no shortage of options for what you are looking to do. As to a hard shutdown you can shutdown the PC using a simple script or as mentioned put it to sleep. Real easy if the PC has a RS232 port or just use an RS232 dongle on any USB port. I am guessing that your PC is setup to run your mining software on boot. Should that be the case you can shut down the running program and then the computer using a simple script. Here is an example:

Code:
Option Explicit
Dim IntCounter
Dim objWshShl : Set objWshShl = WScript.CreateObject("wscript.shell")
Dim objVoice : Set objVoice = WScript.CreateObject("sapi.spvoice")

ShutdownWarning()
TimedMessageBox()
ShutdownComputer()

Function ShutdownWarning
    objVoice.Speak "This computer will now shutdown in 10 seconds."
    WScript.Sleep 5000
End Function

Function TimedMessageBox
    For IntCounter = 5 To 1 Step -1
        objWshShl.Popup "Computer will shutdown in " _
        & IntCounter & " seconds",1,"Computer Shutdown", 0+48
    Next
End Function

Function ShutdownComputer
    objWshShl.Run "Shutdown /s /f /t 0",0
End Function
Open Notepad and paste the above code in notepad. Save the file using Save As and choose All Files. Name the file shutdown.vbs and the .vbs is important. Save it to your desktop (or anywhere convenient. Now double click the file on your desktop. Windows should do a controlled shutdown (assuming you are running Windows). There are dozens of simple scripts like this which can be used for a shutdown, this is one example. The script can be run remotely, this is just a simple desktop example.

You already have LEDs telling you when the solar panel is On/Off.

Heck, here is a real simple solution using an Arduino. Just modify that using the two LED outputs you have.

Ron
 
Last edited:

Thread Starter

Bigfillly

Joined Jan 4, 2019
73
Wow RELOADRON I thank you massively,
Just about all the programming and everything is done, I’m starting now with downloading the arduino again, I’ll let you guys know in a few hours where I am,
Once again THANK YOU
Phil.
 
Last edited:

Thread Starter

Bigfillly

Joined Jan 4, 2019
73
Ok, I’ve downloaded the arduino again,
I’ve created a shortcut on my desktop for shutdown (works great thank you)
I’ve modified the physical pixel sketch to this

const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it's a capital h (ASCII 72), turn on the LED:
if (incomingByte == 'h') {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
}
// if it's an l (ASCII 76) turn off the LED:
if (incomingByte == 'l') {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
}
}
}

I’ve done it so when “h” is pressed the led comes on for a second and when “l” is pressed it also comes on for a second, I just need to know how to make “l” go to the file to shut down the pc,
Mr RELOADRON can you advise me please?
Thanks,
Phil.
 
Last edited:

Thread Starter

Bigfillly

Joined Jan 4, 2019
73
Getting there slowly :)
I’ve ordered the ldr to adapt the program later, just working on how to get the arduino to click into the shutdown file?
Thanks again for your help
 

danadak

Joined Mar 10, 2018
4,057
I have an application where a PC is remote, and has to start up daily and shut down at end of day.

Some BIOSes have a timed start, however this machine I use a simple solar cell
to indicate the day has begun. When solar cell indicates its time to start the UP issues
a 1/2 second pulse thru open drain output wire anded to front panel power switch (which
has a pullup R). It then looks at 12V supply inside PC to see if it started. Reason this was
necessary is PC can be in environmental temps down to sub 0 degree C weather. If power
did not come up I delay for 30 seconds then issue a start pulse again. This is done repeatedly
until PC starts.

To shut down I use windows task manager and setup a time of day shutdown command, with
options to override any running tasks. The command found in /system32/ folder in windows,
is "shutdown.exe".


Regards, Dana.
 
Last edited:

Thread Starter

Bigfillly

Joined Jan 4, 2019
73
Hi danadak,
I really need this to work by sunlight, I like the idea of the task manager timer though, I could use that till I work out everything else, thank you for that :)
 

Thread Starter

Bigfillly

Joined Jan 4, 2019
73
Update is, I was going about the arduino the wrong way with the physical pixel program, I’ve now uploaded the ldr program as I’ll be using that anyway, I’ve done it so an led comes on with anything over 350, I’ve also got a pot to change it if it’s not right,
I am now struggling to get the program to flick the led on for half a second when it goes above 350 but only once and then once again when it drops below 250
How can I rectify this?
I’m only a beginner :-D
Thanks,
Phil.
 

Reloadron

Joined Jan 15, 2015
7,891
I’ve done it so when “h” is pressed the led comes on for a second and when “l” is pressed it also comes on for a second, I just need to know how to make “l” go to the file to shut down the pc,
Mr RELOADRON can you advise me please?
The shutdown sample code I posted is merely one example of dozens which will initiate a shutdown. I am not a programmer type and if I had to rely on my programming skills I would have gone hungry. :)

My guess here would be to use a small code snippet for detecting a onkeydown or a onkeypress event so a script would detect either of those events and then run a shutdown script. So if for example i is pressed ASCI 105 the script will do something like run a shutdown script. The earlier example was done in .vbs (Visual Basic Scripting). This can likely be done in any number of languages or scripting. What we need is someone with a good handle on programming skills.

Ron
 

djsfantasi

Joined Apr 11, 2010
9,237
...just working on how to get the arduino to click into the shutdown file?
AFAIK. You’ll need a program running on the PC waiting for a signal from the Arduino. To get that signal there, you could open the serial port assigned to the Arduino and wait for input. Just like your earlier code, select a character (any character) to look for. Then in your Arduino code, you’d send that character. “serial.print()” will do it.

The problem here is that additional code is required on the PC and it has to be loaded on startup. @Reloadron ’s vbs script could be enhanced to provide this function.

I am now struggling to get the program to flick the led on for half a second when it goes above 350 but only once and then once again when it drops below 250
How can I rectify this?
I’m only a beginner :-D
This is how I’d do it. I’d add two Boolean type variables.
  • Boolean over350 = false;
  • Boolean under250 = false;
In the if statement that check’s if your value is over 350, code it like this:
Code:
if ([I]value[/I] >= 350 && ! over350) {
  over350 = true; under250 = false;
  digitalWrite(ledPin, HIGH);
  delay(1000);
  digitalWrite(ledPin, LOW);
Note that && is the logical AND function and ! is the logical NOT function.

What this statement does is check if the value is over 350 AND it was NOT over350 before. In the code block that follows, you set the Boolean status to true. And flashes the LED once. The LED won’t flash again, because over350 tells the dketch/ program that you’ve already flashed it!

The other if statement is modified similarly.

C:
if ([I]value[/I] <= 250 && ! under250) {
  under250 = true; over350 = false;
  digitalWrite(ledPin, HIGH);
  delay(1000);
  digitalWrite(ledPin, LOW);
}
There is still one flaw in my example, but see if you can grok this.
 

djsfantasi

Joined Apr 11, 2010
9,237
The shutdown sample code I posted is merely one example of dozens which will initiate a shutdown. I am not a programmer type and if I had to rely on my programming skills I would have gone hungry. :)

My guess here would be to use a small code snippet for detecting a onkeydown or a onkeypress event so a script would detect either of those events and then run a shutdown script. So if for example i is pressed ASCI 105 the script will do something like run a shutdown script. The earlier example was done in .vbs (Visual Basic Scripting). This can likely be done in any number of languages or scripting. What we need is someone with a good handle on programming skills.

Ron
That is another way to send a message to the PC. You’d have to use the HID library and just get the keyboard example to work.
 

Thread Starter

Bigfillly

Joined Jan 4, 2019
73
Wow, I’ve just been out for a few hours to the cinema and you have all been busy,
My code is:-

const int ledPin = 13;
const int ldrPin = A0;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(ldrPin, INPUT);
}
void loop() {
int ldrStatus = analogRead(ldrPin);
if (ldrStatus <= 300) {
digitalWrite(ledPin, LOW);
Serial.print("Its DARK, Turn off the LED : ");
Serial.println(ldrStatus);
} else {
digitalWrite(ledPin, HIGH);
Serial.print("Its BRIGHT, Turn on the LED : ");
Serial.println(ldrStatus);
}
}

I know it’s not much different to the standard ldr but I’ll get there,
I’ll get copying and pasting the new add on from DJSFANTASI and see how it performs, then get tweaking,
I have to say a massive thank to all of you, my knowledge of programming is about as basic as a 4 year olds but I’m enjoying it all.
 
Top