How can i save Toogle state in csv?

edited June 2017 in Library Questions

I would like to write a program which works a LED. If the toggle true the white circle has disappear and save the toggle state 1 in csv If the toggle false the white circle has appear and save the toggle state 0 in the same row. But the program just save the same number what i define in int x1 and not the toggle state what i want. Int this point i can get.

import controlP5.*; Table table; ControlP5 cp5;

int col = color(255); controlP5.Toggle b;

boolean setVisible=true; int inside = -1; int x1= 0;

void setup() { size(400,400); smooth();

table = new Table();

cp5 = new ControlP5(this); table.addColumn("kapcsolo1",Table.INT);

TableRow newRow = table.addRow(); newRow.setInt("kapcsolo1", x1);

saveTable(table, "data/new.csv"); // create a toggle and change the default look to a (on/off) switch look b = cp5.addToggle("toggle") .setPosition(40,250) .setSize(50,20) .setValue(true) .setMode(ControlP5.SWITCH) .setVisible(true) ;


void draw() { background(0);


translate(280,100); if(inside==1) ellipse(0,0,100,100);

popMatrix(); }

void toggle(boolean theFlag) { if(theFlag==true) { inside=inside-1; x1=1; } else { inside=inside-1; x1=0; } }


Sign In or Register to comment.