you mean, the code? or this same picture?
Code
int pir = 0;
void setup()
{
pinMode(3, OUTPUT);
pinMode(7, OUTPUT);
pinMode(13, INPUT);
Serial.begin(9600);
}
void loop()
{
pir = digitalRead(13);
Serial.println(pir);
if(pir == 1){
digitalWrite(3, HIGH);
digitalWrite(7, HIGH);
delay(1000);
}else{
digitalWrite(3, LOW);
digitalWrite(7, LOW);
delay(1000);
}
}
i still dont know why my serial monitor is not printing anything
Does the PIR output go HIGH when there is an object detected ?
I assume your serial monitor is configured at 9600.
The PIR modules I have used can be modified so they do not react when there is so much ambient light by adding a photoresistor (LDR). They come with no LDR installed. Any chance your has one already installed? Try obscuring the room.
Usually those "square" 9V batteries supply only low current. Disconnect the motor just to make sure the Arduino + PIR are working.
Also, some PIR modules have the 3 pins in different order. Make sure you are using the correct ones by looking at the PIR module itself.
#define motorON = HIGH
#define motorOFF = LOW
const byte pirPin = 12;
const byte motorPin = 3;
byte pir = 0;
void setup()
{
Serial.begin(9600);
pinMode(motorPin, OUTPUT);
pinMode(pirPin, INPUT);
}
void loop()
{
pir = digitalRead(pirPin);
Serial.println(pir);
digitalWrite(motorPin, pir);
}
yes. but, its not coming out on the monitor
im not using real devices, its a simulation
Try this sketch:
/*
ASCII table
Prints out byte values in all possible formats:
- as raw binary values
- as ASCII-encoded decimal, hex, octal, and binary values
For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII
The circuit: No external hardware needed.
created 2006
by Nicholas Zambetti <http://www.zambetti.com>
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
https://www.arduino.cc/en/Tutorial/BuiltInExamples/ASCIITable
*/
void setup()
{
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial)
{
; // wait for serial port to connect. Needed for native USB port only
}
// prints title with ending line break
Serial.println("ASCII Table ~ Character Map");
}
// first visible ASCIIcharacter '!' is number 33:
int thisByte = 33;
// you can also write ASCII characters in single quotes.
// for example, '!' is the same as 33, so you could also use this:
// int thisByte = '!';
void loop()
{
// prints value unaltered, i.e. the raw binary version of the byte.
// The Serial Monitor interprets all bytes as ASCII, so 33, the first number,
// will show up as '!'
Serial.write(thisByte);
Serial.print(", dec: ");
// prints value as string as an ASCII-encoded decimal (base 10).
// Decimal is the default format for Serial.print() and Serial.println(),
// so no modifier is needed:
Serial.print(thisByte);
// But you can declare the modifier for decimal if you want to.
// this also works if you uncomment it:
// Serial.print(thisByte, DEC);
Serial.print(", hex: ");
// prints value as string in hexadecimal (base 16):
Serial.print(thisByte, HEX);
Serial.print(", oct: ");
// prints value as string in octal (base 8);
Serial.print(thisByte, OCT);
Serial.print(", bin: ");
// prints value as string in binary (base 2) also prints ending line break:
Serial.println(thisByte, BIN);
// if printed last visible character '~' or 126, stop:
if (thisByte == 126) // you could also use if (thisByte == '~') {
{
// This loop loops forever and does nothing
while (true)
{
continue;
}
}
// go on to the next character
thisByte++;
}
please, what kind of diode did you use there?
and please, whats the essence of the "#define"?
im sorry for asking questions that seem simple, i just dont want to assume and be in ignorance
please, can you recommend a youtube channel for me to learn the commands in arduino codes?
i need to understand, not just copy
No, but there many, google and see what kind of thing you like.
This
is one page out of very many that Arduino themselves offer for reference.
You should start with the simple examples on offer in the IDE. Take the time to actually read them and understand how they work. Use google for terms you don't understand, adding Arduino to any search will focus your results.
HTH
a7
Don’t be sorry, asking questions is how we learn.
-
For many hobby type circuits, a diode from the 1N400X family should be fine.
-
This user has a lot of 1N4007 diodes so that’s what he uses .
A 1N4148 diode is also used with many low current motors.
To help learn C++ programming, suggest you watch the first half of the videos offered at this link.
There are quite a few sketch examples that are included with the Arduino IDE.
Here is a link to topics that will help give you a skill set in both hardware and software.
Some items are at a high level, you can skip these and come back to them after you learn the basics.
thank you very much
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.