wanna some help fix error code..
in
Programming Questions
•
1 year ago
thanks to all,
pls help, i wanna do 2 things here
1. wanna create output file hate, hate2, hate3 until hate 6. output entension text format.
2. got error ( red word )
pls help ..
import processing.serial.*;
PrintWriter output;
Serial arduinoPort;
int like = 0;
int hate = 0;
void setup() {
arduinoPort = new Serial(this, Serial.list()[0], 9600);
output = createWriter("counter.txt");
output.println(day()+ "/" + month()+"/"+year());
size(800, 600);
fill(0,0,0);
textSize(14);
text ("friends 1", 100, 230);
text ("friends 2", 120, 230);
text ("friends 3", 130, 230);
text ("friends 4", 140, 230);
text ("friends 5", 150, 230);
text ("friends 6", 160, 230);
fill(256, 256, 256);
rect(100, 250, 100, 100);
fill(256,0,0);
rect(500,500,50,50);
}
void draw() {
byte[] inBuffer = new byte[7];
//int inBuffer = 0;
while (arduinoPort.available() > 0) {
inBuffer = arduinoPort.readBytes();
arduinoPort.readBytes(inBuffer);
if (inBuffer!= null){
//println(inBuffer);
// String myString = new String(inBuffer);
// println(myString);
if(inBuffer[0] == '1'){
like = + 1;
}
if(inBuffer[0] == '2'){
hate = hate + 1;
}
if(inBuffer[0] == '3'){
like2 = like2 + 1;
}
if(inBuffer[0] == '4'){
hate2 = hate2 + 1;
}
if(inBuffer[0] == '5'){
like3 = like3 + 1;
}
if(inBuffer[0] == '6'){
hate3 = hate3 + 1;
}
if(inBuffer[0] == '7'){
like4 = like4 + 1;
}
if(inBuffer[0] == '8'){
hate4 = hate4 + 1;
}
if(inBuffer[0] == '9'){
like5 = like5 + 1;
}
if(inBuffer[0] == '10'){ < here got a problem > from '1' to '9' it's ok. reach '10', got some error "badly formed character constant "
hate5 = hate5 + 1;
}
if(inBuffer[0] == '11'){
like6 = like6 + 1;
}
if(inBuffer[0] == '12'){
hate6 = hate6 + 1;
// tested man
print("like = ");
print(like);
print(" hate = ");
println(hate);
output.println(hour() + ":"+ minute()+"\t"+ like + "\t" + hate);
fill(256, 256, 256);
rect(100, 250, 100, 100);
fill(0,0,0);
text(like, 100, 280);
text(hate, 150, 280);
}
}
}
void keyPressed() { // Press a key to save the data
output.flush(); // Write the remaining data
output.close(); // Finish the file
exit(); // Stop the program
}
void mouseClicked() {
if(mouseX >500 & mouseX < 550){
if(mouseY >500 & mouseY < 550){
output.flush(); // Write the remaining data
output.close(); // Finish the file
exit(); // Stop the program
}
}
}
pls help, i wanna do 2 things here
1. wanna create output file hate, hate2, hate3 until hate 6. output entension text format.
2. got error ( red word )
pls help ..
import processing.serial.*;
PrintWriter output;
Serial arduinoPort;
int like = 0;
int hate = 0;
void setup() {
arduinoPort = new Serial(this, Serial.list()[0], 9600);
output = createWriter("counter.txt");
output.println(day()+ "/" + month()+"/"+year());
size(800, 600);
fill(0,0,0);
textSize(14);
text ("friends 1", 100, 230);
text ("friends 2", 120, 230);
text ("friends 3", 130, 230);
text ("friends 4", 140, 230);
text ("friends 5", 150, 230);
text ("friends 6", 160, 230);
fill(256, 256, 256);
rect(100, 250, 100, 100);
fill(256,0,0);
rect(500,500,50,50);
}
void draw() {
byte[] inBuffer = new byte[7];
//int inBuffer = 0;
while (arduinoPort.available() > 0) {
inBuffer = arduinoPort.readBytes();
arduinoPort.readBytes(inBuffer);
if (inBuffer!= null){
//println(inBuffer);
// String myString = new String(inBuffer);
// println(myString);
if(inBuffer[0] == '1'){
like = + 1;
}
if(inBuffer[0] == '2'){
hate = hate + 1;
}
if(inBuffer[0] == '3'){
like2 = like2 + 1;
}
if(inBuffer[0] == '4'){
hate2 = hate2 + 1;
}
if(inBuffer[0] == '5'){
like3 = like3 + 1;
}
if(inBuffer[0] == '6'){
hate3 = hate3 + 1;
}
if(inBuffer[0] == '7'){
like4 = like4 + 1;
}
if(inBuffer[0] == '8'){
hate4 = hate4 + 1;
}
if(inBuffer[0] == '9'){
like5 = like5 + 1;
}
if(inBuffer[0] == '10'){ < here got a problem > from '1' to '9' it's ok. reach '10', got some error "badly formed character constant "
hate5 = hate5 + 1;
}
if(inBuffer[0] == '11'){
like6 = like6 + 1;
}
if(inBuffer[0] == '12'){
hate6 = hate6 + 1;
// tested man
print("like = ");
print(like);
print(" hate = ");
println(hate);
output.println(hour() + ":"+ minute()+"\t"+ like + "\t" + hate);
fill(256, 256, 256);
rect(100, 250, 100, 100);
fill(0,0,0);
text(like, 100, 280);
text(hate, 150, 280);
}
}
}
void keyPressed() { // Press a key to save the data
output.flush(); // Write the remaining data
output.close(); // Finish the file
exit(); // Stop the program
}
void mouseClicked() {
if(mouseX >500 & mouseX < 550){
if(mouseY >500 & mouseY < 550){
output.flush(); // Write the remaining data
output.close(); // Finish the file
exit(); // Stop the program
}
}
}
1