Mit Jelentenek? Már több helyen találkoztam velük. Az ardunio honlapján is nézegettem fordítón keresztül de nem sikerült megfeljeni mit is csinálnak.
serial.begin(9600)
serial.println
serial.print
Soros kommunikáció - alapkérdések...
- benzinkutas
- DrótVégénSzéndarab
- Hozzászólások: 31
- Csatlakozott: 2011. április 30. szombat, 6:00
- benzinkutas
- DrótVégénSzéndarab
- Hozzászólások: 31
- Csatlakozott: 2011. április 30. szombat, 6:00
Nem értem!
Ez a kis programocskát az arduino.cc-ről másoltam ki. Egy led fény erejét változtatja a potméter ellenállásától függően. Ezt én úgy oldottam meg hogy a nullás analóg bemeneten olvastam a poti értékét majd néggyel való osztás után az eredményt egy PWM kimenetre Írtam. Kérdés: miéer jobb ez így és ebben a példában mit csinál serial.begin(9600) serial.println, serial.print, map(sensorValue, 0, 1023, 0, 255);? Minek a soros portját állítja be? És hol vannak itt stringek?
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
// wait 10 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(10);
}
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
// wait 10 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(10);
}
Re: Nem értem!
Sziasztok,
nem vagyok egy C guru, de ez egyszerűnek tűnik:
Ugyan azt csinálja mint a te programod:
analogRead = Analóg bemenet beolvasása
Map = ez egy hozzá rendelés (MAP-pelés) gyakorlatilag itt 4-el való osztás
nem ismerem pontosan a map függvényt de egy lineáris megfeleltetést végez (0 nak a 0 felel meg, 1023 nak a 255)
rajzold fel és meglátod
AnalogWrite = gondolom ez a pwm kimenet
Pluszban kiküldi mind a mért mind a pwm értékét soros buszon
Üdv,
Csaba
nem vagyok egy C guru, de ez egyszerűnek tűnik:
Ugyan azt csinálja mint a te programod:
analogRead = Analóg bemenet beolvasása
Map = ez egy hozzá rendelés (MAP-pelés) gyakorlatilag itt 4-el való osztás
nem ismerem pontosan a map függvényt de egy lineáris megfeleltetést végez (0 nak a 0 felel meg, 1023 nak a 255)
rajzold fel és meglátod
AnalogWrite = gondolom ez a pwm kimenet
Pluszban kiküldi mind a mért mind a pwm értékét soros buszon
Üdv,
Csaba
benzinkutas írta:Ez a kis programocskát az arduino.cc-ről másoltam ki. Egy led fény erejét változtatja a potméter ellenállásától függően. Ezt én úgy oldottam meg hogy a nullás analóg bemeneten olvastam a poti értékét majd néggyel való osztás után az eredményt egy PWM kimenetre Írtam. Kérdés: miéer jobb ez így és ebben a példában mit csinál serial.begin(9600) serial.println, serial.print, map(sensorValue, 0, 1023, 0, 255);? Minek a soros portját állítja be? És hol vannak itt stringek?
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
// wait 10 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(10);
}
Ha ennyire kezdő vagy ajánlom a Fő oldalon levő „Bascom leírás illetve könyv” olvasását!
http://avr.tavir.hu/modules.php?name=Co ... ies&cid=15

És +: Felhasználói dokumentáció
http://avr.tavir.hu/modules.php?name=Do ... oad&cid=10

http://avr.tavir.hu/modules.php?name=Co ... ies&cid=15
És +: Felhasználói dokumentáció
http://avr.tavir.hu/modules.php?name=Do ... oad&cid=10
