Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

ENERGIA AND PROCESSING

$
0
0
I am trying to run an Arduino program on MSP-430G2452 using Energia. My code is sending data to PROCESSING(I.D.E.) on my computer via usb, to change the colour of a box(made using processing) when a switch is pressed. But it seems that the processing is not receiving anything from the board . Can anybody please tell me what wrong I am doing ? The same code is running properly with the Arduino! CODE FOR ENERGIA: int switchPin = 6; int LEDPin = 2; void setup() { pinMode (switchPin, INPUT_PULLUP); pinMode (LEDPin, OUTPUT); Serial.begin(4800); } void loop() { if (digitalRead(switchPin) == HIGH) { Serial.write(2); digitalWrite(LEDPin, LOW); } else { Serial.write(1); digitalWrite(LEDPin, HIGH); } delay(100); } CODE FOR PROCESSING: import processing.serial.*; Serial port; int val; void setup() { size(400, 400); noStroke(); frameRate(10); println(Serial.list()); // print a list of all available ports port = new Serial(this, "COM4", 4800); } void draw() { if (0 < port.available()) { val = port.read(); } background(204); if (val == 1) { fill(255, 127, 0); // fill orange } else { fill(0, 170, 0); // fill green } rect(50, 50, 300, 300); }

Viewing all articles
Browse latest Browse all 2077

Trending Articles