Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!




Arduino - engine co...
 
Share:
Notifications
Clear all

Arduino - engine control with ecg module

2 Posts
2 Users
0 Likes
964 Views
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

hi everyone, I'm a newbie with Arduino and in desperate need for help! I study industrial design and am working on a project where I want to have a little engine with a counterweight (like you find in electric toothbrushes, vibrators...) be controlled by the signals read by this ecg module: https://how2electronics.com/ecg-monitoring-with-ad8232-ecg-sensor-arduino/

furthermore I am using a mosfet to control the voltage that starts/stops the engine, like this: https://electropeak.com/learn/interfacing-irf520-mosfet-driver-module-switch-button-hcmodu0083-with-arduino/

both of those setups work fine for themselves, and since I had the manual and all the information it was easy even for me to get everything running. But since my knowledge doesn't go any further than that, I am a bit lost now. How do I have to connect the hardware, and how do I re-write the code to get it to work? I've been copy-pasting the codes on the websites posted above.

Hopefully this post describes well enough what I'm trying to do. I'd be happy to answer any more questions or show some pics of what I've got so far. Any help would be greatly appreciated!

 

Edit: title

This topic was modified 2 years ago by Anonymous

   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2654
 

Hi Pimi,

welcome to the forum!

Unfortunately, I have no experience with either. Looking at both projects though, I do not see a conflict in wiring - well, except for the potentiometer. You can leave that one out since you're using the ECG data instead.

So connect it as the shown in the ECG example:

And next add the motor wiring leaving out the potentiometer. So leave the wires from the first circuit and ADD these:

Combining code (without modifying anything - and both functions work as before) should not be a problem either.

This could look something like this, where I presume you'd want the ECG data to be used as an input for the motor.

#define PWM 3
int pot;
int out;

void setup() {
  // initialize the serial communication:
  Serial.begin(9600);
  pinMode(10, INPUT); // Setup for leads off detection LO +
  pinMode(11, INPUT); // Setup for leads off detection LO -
  pinMode(PWM,OUTPUT);
}
 
void loop() {
  pot=analogRead(A0);
  
  if((digitalRead(10) == 1)||(digitalRead(11) == 1)){
    Serial.println('!');
  } else{
    // send the value of analog input 0:
    Serial.println(pot);
  }
  
  out=map(pot,0,1023,0,255);
  analogWrite(PWM,out);
  
  delay(1); // may longer be needed
}

 

Note: I do not have any of these components and I have zero experience with these either. So the code is untested.
But I'm confident this will get you close to what you may have had in mind. 😊 


   
ReplyQuote

Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).

Share: