Skip to main content
Formatted code, added tag.
Source Link
ocrdu
  • 1.8k
  • 3
  • 12
  • 24

I am using an Arduino Atmega2560 clone, I have used it many times before with satisfactory results - although I haven't used it with my Rpi before.

My Raspberry Pi is model 4 (B I think?).

#define knap 49
#define motorOutput 8

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(knap,INPUT);
  pinMode(motorOutput,OUTPUT);
  digitalWrite(motorOutput,LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
int knapSensor = digitalRead(knap);
Serial.print(knapSensor);
if (knapSensor == 1){
  int knapSensor = digitalRead(knap);
  Serial.print("aktiveret");
  digitalWrite(motorOutput,HIGH);
  delay(500);
  digitalWrite(motorOutput,LOW);
  }
}
#define knap 49
#define motorOutput 8

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(knap, INPUT);
  pinMode(motorOutput, OUTPUT);
  digitalWrite(motorOutput, LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
  int knapSensor = digitalRead(knap);
  Serial.print(knapSensor);
  if (knapSensor == 1) {
    int knapSensor = digitalRead(knap);
    Serial.print("aktiveret");
    digitalWrite(motorOutput, HIGH);
    delay(500);
    digitalWrite(motorOutput, LOW);
  }
}

Now I have double checked, the motor and the button is wired correctly. There is no hardware issue, aside from the cables being sh- quality.

Problem is, whenever I run this program two things will happen;

Either it starts fine by displaying "0000..." on the serial monitor.

Then when I press the button it goes to "AktiveretAktiveretAktiveret..." even when I depress the button.

Or, it will just display "AktiveretAktiveretAktiveret...".

In either case the motor won't work.

Once again, I have done tests where I have removed the power from the breadboard and replaced the voltage pin for the motor with the voltage pin leading from the button.

First thing didn't change the input (i.e still "AktiveretAktiveret,") the latter started the motor.

I.e this isn't about bad wiring.

EDIT:

Added schematics and changed the code

enter image description here

I am using an Arduino Atmega2560 clone, I have used it many times before with satisfactory results - although I haven't used it with my Rpi before.

My Raspberry Pi is model 4 (B I think?).

#define knap 49
#define motorOutput 8

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(knap,INPUT);
  pinMode(motorOutput,OUTPUT);
  digitalWrite(motorOutput,LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
int knapSensor = digitalRead(knap);
Serial.print(knapSensor);
if (knapSensor == 1){
  int knapSensor = digitalRead(knap);
  Serial.print("aktiveret");
  digitalWrite(motorOutput,HIGH);
  delay(500);
  digitalWrite(motorOutput,LOW);
  }
}

Now I have double checked, the motor and the button is wired correctly. There is no hardware issue, aside from the cables being sh- quality.

Problem is, whenever I run this program two things will happen;

Either it starts fine by displaying "0000..." on the serial monitor.

Then when I press the button it goes to "AktiveretAktiveretAktiveret..." even when I depress the button.

Or, it will just display "AktiveretAktiveretAktiveret...".

In either case the motor won't work.

Once again, I have done tests where I have removed the power from the breadboard and replaced the voltage pin for the motor with the voltage pin leading from the button.

First thing didn't change the input (i.e still "AktiveretAktiveret,") the latter started the motor.

I.e this isn't about bad wiring.

EDIT:

Added schematics and changed the code

enter image description here

I am using an Arduino Atmega2560 clone, I have used it many times before with satisfactory results - although I haven't used it with my Rpi before.

My Raspberry Pi is model 4 (B I think?).

#define knap 49
#define motorOutput 8

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(knap, INPUT);
  pinMode(motorOutput, OUTPUT);
  digitalWrite(motorOutput, LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
  int knapSensor = digitalRead(knap);
  Serial.print(knapSensor);
  if (knapSensor == 1) {
    int knapSensor = digitalRead(knap);
    Serial.print("aktiveret");
    digitalWrite(motorOutput, HIGH);
    delay(500);
    digitalWrite(motorOutput, LOW);
  }
}

Now I have double checked, the motor and the button is wired correctly. There is no hardware issue, aside from the cables being sh- quality.

Problem is, whenever I run this program two things will happen;

Either it starts fine by displaying "0000..." on the serial monitor.

Then when I press the button it goes to "AktiveretAktiveretAktiveret..." even when I depress the button.

Or, it will just display "AktiveretAktiveretAktiveret...".

In either case the motor won't work.

Once again, I have done tests where I have removed the power from the breadboard and replaced the voltage pin for the motor with the voltage pin leading from the button.

First thing didn't change the input (i.e still "AktiveretAktiveret,") the latter started the motor.

I.e this isn't about bad wiring.

EDIT:

Added schematics and changed the code

enter image description here

added 38 characters in body
Source Link

I am using an Arduino Atmega2560 clone, I have used it many times before with satisfactory results - although I haven't used it with my Rpi before.

My Raspberry Pi is model 4 (B I think?).

#define knap 49
#define motorOutput 8

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(knap,INPUT);
  pinMode(motorOutput,OUTPUT);
  digitalWrite(motorOutput,LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
int knapSensor = digitalRead(knap);
Serial.print(knapSensor);
if (knapSensor == 1){
  int knapSensor = digitalRead(knap);
  Serial.print("aktiveret");
  digitalWrite(motorOutput,HIGH);
  delay(500);
  digitalWrite(motorOutput,LOW);
  }
}

Now I have double checked, the motor and the button is wired correctly. There is no hardware issue, aside from the cables being sh- quality.

Problem is, whenever I run this program two things will happen;

Either it starts fine by displaying "0000..." on the serial monitor.

Then when I press the button it goes to "AktiveretAktiveretAktiveret..." even when I depress the button.

Or, it will just display "AktiveretAktiveretAktiveret...".

In either case the motor won't work.

Once again, I have done tests where I have removed the power from the breadboard and replaced the voltage pin for the motor with the voltage pin leading from the button.

First thing didn't change the input (i.e still "AktiveretAktiveret,") the latter started the motor.

I.e this isn't about bad wiring.

EDIT:

Added schematics and changed the code

enter image description here

I am using an Arduino Atmega2560 clone, I have used it many times before with satisfactory results - although I haven't used it with my Rpi before.

My Raspberry Pi is model 4 (B I think?).

#define knap 49
#define motorOutput 8

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(knap,INPUT);
  pinMode(motorOutput,OUTPUT);
  digitalWrite(motorOutput,LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
int knapSensor = digitalRead(knap);
Serial.print(knapSensor);
if (knapSensor == 1){
  int knapSensor = digitalRead(knap);
  Serial.print("aktiveret");
  digitalWrite(motorOutput,HIGH);
  delay(500);
  }
}

Now I have double checked, the motor and the button is wired correctly. There is no hardware issue, aside from the cables being sh- quality.

Problem is, whenever I run this program two things will happen;

Either it starts fine by displaying "0000..." on the serial monitor.

Then when I press the button it goes to "AktiveretAktiveretAktiveret..." even when I depress the button.

Or, it will just display "AktiveretAktiveretAktiveret...".

In either case the motor won't work.

Once again, I have done tests where I have removed the power from the breadboard and replaced the voltage pin for the motor with the voltage pin leading from the button.

First thing didn't change the input (i.e still "AktiveretAktiveret,") the latter started the motor.

I.e this isn't about bad wiring.

EDIT:

Added schematics and changed the code

enter image description here

I am using an Arduino Atmega2560 clone, I have used it many times before with satisfactory results - although I haven't used it with my Rpi before.

My Raspberry Pi is model 4 (B I think?).

#define knap 49
#define motorOutput 8

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(knap,INPUT);
  pinMode(motorOutput,OUTPUT);
  digitalWrite(motorOutput,LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
int knapSensor = digitalRead(knap);
Serial.print(knapSensor);
if (knapSensor == 1){
  int knapSensor = digitalRead(knap);
  Serial.print("aktiveret");
  digitalWrite(motorOutput,HIGH);
  delay(500);
  digitalWrite(motorOutput,LOW);
  }
}

Now I have double checked, the motor and the button is wired correctly. There is no hardware issue, aside from the cables being sh- quality.

Problem is, whenever I run this program two things will happen;

Either it starts fine by displaying "0000..." on the serial monitor.

Then when I press the button it goes to "AktiveretAktiveretAktiveret..." even when I depress the button.

Or, it will just display "AktiveretAktiveretAktiveret...".

In either case the motor won't work.

Once again, I have done tests where I have removed the power from the breadboard and replaced the voltage pin for the motor with the voltage pin leading from the button.

First thing didn't change the input (i.e still "AktiveretAktiveret,") the latter started the motor.

I.e this isn't about bad wiring.

EDIT:

Added schematics and changed the code

enter image description here

added 60 characters in body
Source Link

I am using an Arduino Atmega2560 clone, I have used it many times before with satisfactory results - although I haven't used it with my Rpi before.

My Raspberry Pi is model 4 (B I think?).

   #define knap 49
#define motorOutput 8

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(knap,INPUT);
  pinMode(motorOutput,OUTPUT);
  digitalWrite(motorOutput,LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
int knapSensor = digitalRead(knap);
Serial.print(knapSensor);
whileif (knapSensor == 1){
  int knapSensor = digitalRead(knap);
  Serial.print("aktiveret");
  digitalWrite(motorOutput,HIGH);
  delay(500);
  }
}

Now I have double checked, the motor and the button is wired correctly. There is no hardware issue, aside from the cables being sh- quality.

Problem is, whenever I run this program two things will happen;

Either it starts fine by displaying "0000..." on the serial monitor.

Then when I press the button it goes to "AktiveretAktiveretAktiveret..." even when I depress the button.

Or, it will just display "AktiveretAktiveretAktiveret...".

In either case the motor won't work.

Once again, I have done tests where I have removed the power from the breadboard and replaced the voltage pin for the motor with the voltage pin leading from the button.

First thing didn't change the input (i.e still "AktiveretAktiveret,") the latter started the motor.

I.e this isn't about bad wiring.

EDIT:

Added schematics and changed the code

enter image description here

I am using an Arduino Atmega2560 clone, I have used it many times before with satisfactory results - although I haven't used it with my Rpi before.

My Raspberry Pi is model 4 (B I think?).

   #define knap 49
#define motorOutput 8

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(knap,INPUT);
  pinMode(motorOutput,OUTPUT);
  digitalWrite(motorOutput,LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
int knapSensor = digitalRead(knap);
Serial.print(knapSensor);
while (knapSensor == 1){
  Serial.print("aktiveret");
  digitalWrite(motorOutput,HIGH);
  delay(500);
  }
}

Now I have double checked, the motor and the button is wired correctly. There is no hardware issue, aside from the cables being sh- quality.

Problem is, whenever I run this program two things will happen;

Either it starts fine by displaying "0000..." on the serial monitor.

Then when I press the button it goes to "AktiveretAktiveretAktiveret..." even when I depress the button.

Or, it will just display "AktiveretAktiveretAktiveret...".

In either case the motor won't work.

Once again, I have done tests where I have removed the power from the breadboard and replaced the voltage pin for the motor with the voltage pin leading from the button.

First thing didn't change the input (i.e still "AktiveretAktiveret,") the latter started the motor.

I.e this isn't about bad wiring.

EDIT:

Added schematics

enter image description here

I am using an Arduino Atmega2560 clone, I have used it many times before with satisfactory results - although I haven't used it with my Rpi before.

My Raspberry Pi is model 4 (B I think?).

#define knap 49
#define motorOutput 8

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(knap,INPUT);
  pinMode(motorOutput,OUTPUT);
  digitalWrite(motorOutput,LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
int knapSensor = digitalRead(knap);
Serial.print(knapSensor);
if (knapSensor == 1){
  int knapSensor = digitalRead(knap);
  Serial.print("aktiveret");
  digitalWrite(motorOutput,HIGH);
  delay(500);
  }
}

Now I have double checked, the motor and the button is wired correctly. There is no hardware issue, aside from the cables being sh- quality.

Problem is, whenever I run this program two things will happen;

Either it starts fine by displaying "0000..." on the serial monitor.

Then when I press the button it goes to "AktiveretAktiveretAktiveret..." even when I depress the button.

Or, it will just display "AktiveretAktiveretAktiveret...".

In either case the motor won't work.

Once again, I have done tests where I have removed the power from the breadboard and replaced the voltage pin for the motor with the voltage pin leading from the button.

First thing didn't change the input (i.e still "AktiveretAktiveret,") the latter started the motor.

I.e this isn't about bad wiring.

EDIT:

Added schematics and changed the code

enter image description here

added 120 characters in body
Source Link
Loading
Source Link
Loading