hi everyone!
i hope to get help with that, because i quite confused.
i tried do write a code for letting pictures appear at the computerscreen to the activations of pushbuttons. there are 7 pushbottons and each one has its dedicated picture.
but i have several problems:
i dont know how to define the output correctly?
as well i cant say whats the right command for that kind of coding, is it serial.write or serial.print or digital.write... or what else..?
also i dont know if arduino or processing are able to project pictures, so i was looking for an converter and found that:
http://www.henningkarlsen.com/electronics/t_imageconverter565.php
but its not really working...
im a real beginner!!! bloody beginner! i didnt have problems to modificate the examples but this is beyond me!!
please, could somebody help me out?
have to finish that project this week! :-/
thanks!
here the code:
// 7 pushbuttons, any of them initiating a picture
//------------------ATTRIBUT --------------------------------
// Buttons
int buttonPin = 0;
int buttonPin2 = 2;
int buttonPin3 = 3;
int buttonPin4 = 4;
int buttonPin5 = 5;
int buttonPin6 = 6;
int buttonPin7 = 7;
int buttonPin8 = 8;
// which apparat?
//pictures
int pic2 = 2.jpeg;
int pic3 = 3.jpeg;
int pic4 = 4.jpeg;
int pic5 = 5.jpeg;
int pic6 = 6.jpeg;
int pic7 = 7.jpeg;
int pic8 = 8.jpeg;
// Variable?
int buttonState = 0;
// --------------Method to read the buttons--------
void setup() {
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
pinMode(buttonPin5, INPUT);
pinMode(buttonPin6, INPUT);
pinMode(buttonPin7, INPUT);
pinMode(buttonPin8, INPUT);
pinMode(pic2, OUTPUT);
pinMode(pic3, OUTPUT);
pinMode(pic4, OUTPUT);
pinMode(pic5, OUTPUT);
pinMode(pic6, OUTPUT);
pinMode(pic7, OUTPUT);
pinMode(pic8, OUTPUT);
//serial.write,OUTPUT;
}
void loop() {
// what method for digitalRead?
int reading = digitalRead(buttonPin);
buttonState = digitalRead(buttonPin);
// says what arduino hace to do, if you are pushing button2
// better Try {....} catch {...}?
// or case0 {...}, case 1...
if (buttonState "buttonPin2" == HIGH) {
// method to et the image appear, eg:
pic2= loadImage ("img/2.jpg");
}
// or: Serial.println("img/2.jpg"); ?
// or: JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
File datei = new File( "2.jpeg" );
BufferedImage bild = ImageIO.read(2.jpeg);
// Bild anzeigen
JLabel label = new JLabel(new ImageIcon(bild));
frame.getContentPane().add(label);
frame.pack();
frame.setVisible(true);
else if (buttonState buttonPin2 == LOW) default;
// default ending the process, if button no longer is pressed
else if (buttonState buttonPin3 == HIGH)
..
..
..
..
else (buttonState buttonPin8 == LOW) default
}
}
hope thats not completly rubbish and it more or less easy to solve... :-/
thanks for commenting!
lkjh