עבור לתוכן

שלום חברים, אני משתמש חדש באנדרואינו והנה הפרוייקט הראשון שלי!

Featured Replies

פורסם

רק השבוע הגיע אליי הבקר UNO 3 אנדרואינו, הבקר הגיע עם ערכה בסיסית של רכיבים.

לאחר מספר ניסיונות ודפיקות על השולחן למה לא מצליח להתקין ושמערכת ההפעלה סוף סוף תתחבר אליו, הצלחתי לעשות זאת.

כמו כן מההתלהבות בחנתי בידיים כל חלק ורכיב שהגיעו בערכה וממש לא יכלתי לחכות ולהתחיל לבנות מעגל ראשוני.

כמו הרבה המלצות ומדריכים, כולם בחרו על מעגל להדלקת לד

כמובן שעשיתי זאת אבל זה לא סיפק אותי, רציתי לעשות משהו יותר מורכב והנה הפרטים למעגל שעשיתי:

רציתי לעשות הפעלה של לד באמצאות חיישן אור - PHOTOCELL, שישלוט על 2 לדים ולכל לד יש טווח זיהוי מתחים אחרים

ראו שרטוט שעשיתי, במידה ויש לכם שאלות על מעגל זה, אשמח לעזור לכם.

<a  href=%7Boption%7Dhttp://i1031.photobucket.com/albums/y374/orenfafa/Adruino/Control2ledswith1photocellSketch_bb_zps015b387a.jpg' alt='Control2ledswith1photocellSketch_bb_zps015b387a.jpg'>

/*
Analog input, analog output, serial output

Reads an analog input pin, maps the result to a range from 0 to 255
and uses the result to set the pulsewidth modulation (PWM) of an output pin.
Also prints the results to the serial monitor.

The circuit:
* potentiometer connected to analog pin 0.
Center pin of the potentiometer goes to the analog pin.
side pins of the potentiometer go to +5V and ground
* LED connected from digital pin 9 to ground

created 29 Dec. 2008
modified 9 Apr 2012
by Tom Igoe

This example code is in the public domain.

*/

// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin0 = A0; // Analog input pin that the potentiometer is attached to
const int analogInPin1 = A2; // Analog input pin that the potentiometer is attached to
const int analogOutPin10 = 9; // Analog output pin that the LED is attached to
const int analogOutPin3 = 10; // Analog output pin that the LED is attached to

int sensorValue0 = 0; // value read from the pot
int outputValue0 = 0; // value output to the PWM (analog out)
int sensorValue1 = 0; // value read from the pot
int outputValue1 = 0; // value output to the PWM (analog out)

void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}

void loop() {
// read the analog in value:
sensorValue0 = analogRead(analogInPin0);
sensorValue1 = analogRead(analogInPin1);
// map it to the range of the analog out:
outputValue0 = map(sensorValue0, 200, 550, 0, 255);
outputValue1 = map(sensorValue1, 200, 550, 0, 255);
// change the analog out value:
analogWrite(analogOutPin10, outputValue0);
analogWrite(analogOutPin3, outputValue1);
//digitalWrite(13, HIGH);

if (outputValue0 > 288) {
digitalWrite(analogOutPin10, LOW);
//digitalWrite(analogOutPin3, LOW);
}

if (outputValue1 > 200) {
digitalWrite(analogOutPin3, LOW);
}

// print the results to the serial monitor:
Serial.print("sensor1 = " );
Serial.print(sensorValue0);
Serial.print("\t output1 = ");
Serial.println(outputValue0);
Serial.print("sensor2 = " );
Serial.print(sensorValue1);
Serial.print("\t output2 = ");
Serial.println(outputValue1);
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(3);
}

נערך על-ידי orenfafa

פורסם

שים את הקוד שלך בטאג קוד (בעורך המתקדם->תמונה של סולמית #)

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים