can the arduino mega do this?

i have an extra arduino mega and i want to use it for something quite simple. I have a custom switch on my laptop and want to wire the arduino in insteed of the switch so that when the ardunio gets power it works as a momentary switch for 1-2 seconds then turns off. the input of the cable is 3.3 v and i want that signal just passed through the arduino almost as an automatic momentary switch to turn my laptop on when ever it gets power. i also want to add the momentary switch to the circuit so that if i tap it it triggers the momentary 1-2 seconds switch and if i hold the switch down it connects the two lines until i let go of the switch. If anyone could help me with the coding or tell me if this is even possible i would appriciate i as im not a programmer. if anyone needs me to draw an amature diagram to understand what i mean feel free to let me know. it'll prob look like a piccaso from china but hey, as long as it gets the job done lol

ps. if anyone wants to know what its for, im building a guitar loop station pedalboard with a lot of built in stuff, incuding a torndown laptop. and i want this to functions as an automatic power on when i plug the pedalboard into power (i will not be using the laptop battery) as this would make things easier when seeting up for live gigs.

i have an extra arduino mega and i want to use it for something quite simple. I have a custom switch on my laptop and want to wire the arduino in insteed of the switch so that when the ardunio gets power it works as a momentary switch for 1-2 seconds then turns off. the input of the cable is 3.3 v and i want that signal just passed through the arduino almost as an automatic momentary switch to turn my laptop on when ever it gets power. i also want to add the momentary switch to the circuit so that if i tap it it triggers the momentary 1-2 seconds switch and if i hold the switch down it connects the two lines until i let go of the switch. If anyone could help me with the coding or tell me if this is even possible i would appriciate i as im not a programmer. if anyone needs me to draw an amature diagram to understand what i mean feel free to let me know. it'll prob look like a piccaso from china but hey, as long as it gets the job done lol

ps. if anyone wants to know what its for, im building a guitar loop station pedalboard with a lot of built in stuff, incuding a torndown laptop. and i want this to functions as an automatic power on when i plug the pedalboard into power (i will not be using the laptop battery) as this would make things easier when seeting up for live gigs.

It looks possible, provided that you didn't omit essential information.
Have a look at the Debounce and StateChangeDetection examples for handling switches.
Optocouplers can be used for safe signal transmission between the Arduino and the laptop.

Sounds like a grossly inappropriate use of a Mega 2560. :astonished:

A Pro Mini would be far more suitable. :sunglasses:

Just check there isn’t a setting in bios that will allow your laptop to do this automatically by itself ?

Accessing parts of the keyboard might be difficult - have a look at “wake on lan”as another possible route

Too much info missing

I have a custom switch on my laptop

which laptop? what is a custom switch?

the input of the cable is 3.3 v

which cable? is that to power the Arduino? how many amps available? where does this come from?

turn my laptop on when ever it gets power

I don't get it. if the PC is off, does the 'custom switch' work? how do you plan to turn on the PC - is there a physical switch to flip?

I think you should draw a diagram of all the components you've mentioned including any separate power supplies.
In principle, you can use a relay module as a switch replacement. However, using an Arduino Mega for the simple task of providing a 1-2 second activation of a relay module appears, on the face of it, to be overkill.

Duplicate topics moved to a common forum section and merged

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a timeout from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Paul__B:
Sounds like a grossly inappropriate use of a Mega 2560. :astonished:

A Pro Mini would be far more suitable. :sunglasses:

The smallest attiny would be even more appropriate.

hammy:
Just check there isn’t a setting in bios that will allow your laptop to do this automatically by itself ?

That is the first place I'd be looking, almost all desktops will have the ability to turn on either at a specific time, or resume the same state as when power was lost (in other works, turn back on automatically if the computer was running when power was lost). Not sure if I've even looked at a laptop bios to see if that setting exists.

What exactly are you using the laptop for? Sounds kind of excessive for the application.

so im programing an arduino mega to turn on a pc and the program works.. kind of
to turn on the pc i need the ardunio to send a 3.3v signal to the pc. that part works. i also want to add in a momentary switch to be able to turn the signal (3.3v) on again for 1 second to turn the pc off. the problem is that when i run the program the first part of it seem to loop. i have put a 5 seconds delay on it so that the pc has the time to charge up before it turns on. so whats happening is that the arduino send the 3.3 v signal after 5 seconds, turns off, waits 5 seconds then sends the signal again. i dont know if its something in the code that is incorrect or what. could really use some help.

so to be clear, i want it to wait 5 seconds when the arduino gets power, thensend a 3.3v signal for 1 second then do nothing until i press the switch

here is the code

int button=8;

void setup() {
// put your setup code here, to run once:
pinMode(button, INPUT);
pinMode(12, OUTPUT) ;
}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite (12, LOW) ;
delay(5000) ;
digitalWrite(12, HIGH) ;
delay(1000);
digitalWrite(12, LOW) ;
if (button, LOW){
digitalWrite(12, HIGH);
delay(1000);
digitalWrite(12, LOW);
}
}

If you want to run something only once, you can put it in setup() instead of in loop().

What is this ?

if (button, LOW){

thats the momentary switch, i read that low on an input is when its pressed down

patricklou15:
thats the momentary switch, i read that low on an input is when its pressed down

That is not how you read the state of a pin. You need to use digitalRead() and test the value that is returned. See the Button example in the IDE

How is the input pin wired ?

And if you look at some code examples you'll never see an if statement that looks like that. Because , (comma) isn't a comparison. == is a comparison. So are < > != etc.

Steve

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.