Beste,
Ik heb een Motorshield gebouwd voor de arduino duemilanove ATMEGA328.
Nu was het de bedoeling om 4 motortjes(dc motortjes) te sturen (enkel maar aan en uit te zetten.. met een sensor..
Deze is de motorshield:
http://www.ladyada.net/make/mshield/use.html
Ik heb gekeken welke pinnen de motorshield in gebruik nam, en kwam tot het besluit dat ik nog 2 digitale pinnen vrij had, de 2de en de 13de.
"What pins are not used on the motor shield?
All 6 analog input pins are available. They can also be used as digital pins (pins #14 thru 19)
Digital pin 2, and 13 are not used.
Digital pin 11: DC Motor #1 / Stepper #1 (activation/speed control)
Digital pin 3: DC Motor #2 / Stepper #1 (activation/speed control)
Digital pin 5: DC Motor #3 / Stepper #2 (activation/speed control)
Digital pin 6: DC Motor #4 / Stepper #2 (activation/speed control)
These pins are in use only if the DC/Stepper noted is in use
Digital pin 4, 7, 8 and 12 are used to drive the DC/Stepper motors via the 74HC595 serial-to-parallel latch
These pins are in use if any DC/steppers are used
Digitals pin 9: Servo #1 control
Digital pin 10: Servo #2 control
These pins are used only if that particular servo is in use"
De sensor(clock en datapin) is zowel op een arduino met een lcd aangesloten als op een andere arduino met motorshield.
De waardes op het lcd varieren.. van -40 tot 25 tot 10 ...
Als ik alleen de sensor op het lcd aansluit kloppen de waardes.
De broncode van het lcd en sensor is juist.
Zie hier:
#include <Wire.h>
#include <LiquidCrystal.h>
#include <SHT1x.h>
#define dataPin 9
#define clockPin 8
SHT1x sht1x(dataPin, clockPin);
float temp_c;
float humidity;
LiquidCrystal lcd(12,11,5,4,3,2);
void setup()
{
lcd.begin(16,2);
lcd.clear();
}
void loop()
{
temp_c = sht1x.readTemperatureC();
humidity = sht1x.readHumidity();
lcd.setCursor(0,0); // 1ste Rij LCD
lcd.print("Temp: ");
lcd.print(temp_c);
lcd.print((char)223); // Graden symbool
lcd.print("c");
lcd.setCursor(0,1); // 2de Rij LCD
lcd.print("Vocht:");
lcd.print(humidity);
lcd.print("%");
} En die van de 2de arduino (met motorshield, en sensor), waarvan ik niet zeker weet of deze code juist is..(dit is maar het begin met 1 motor)
#include <AFMotor.h>
#include <SHT1x.h>
#define dataPin 2
#define clockPin 13
AF_DCMotor motor(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
SHT1x sht1x(dataPin, clockPin);
float temp_c;
float humidity;
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");
motor.setSpeed(200); // set the speed to 200/255
}
void loop()
{
temp_c = sht1x.readTemperatureC();
humidity = sht1x.readHumidity();
if(temp_c < 20.00)
{
Serial.print("tick");
motor.run(FORWARD); // turn it on going forward
delay(1000);
}
if(temp_c > 20.00)
{
Serial.print("tack");
motor.run(RELEASE); // stopped
delay(1000);
}
}
Zou mij iemand kunnen zeggen waar het fout loopt?
Met vriendelijke groeten,
Maxim
pros
Prosper, yop la boum, c'est le roi du macadam (aldus Maurice Chevalier)
De sensor(clock en datapin) is zowel op een arduino met een lcd aangesloten als op een andere arduino met motorshield.
Dat lijkt me geen goed idee. Zo knoop je toch twee uitgangspinnen (clock) van verschillende AVR's samen?