Print Variable: Output Variable's Value to the User
You learned how to assign a numerical value to a variable and use that variable in your program. The print variable block (or printf() code in Ch) can then print out the current numerical value of that variable.
The print variable block is found in the Text menu. Watch the lesson video to learn more about how to use it.
Since the video was created, the way this print block works has been changed slightly. Instead of printing the result in a popup window, it opens a printing "Console" below the Workspace and displays the printed result there. (Click the "Console" button next to the "Show Ch" button to toggle the Console open or closed.) This change allows us to see the results of multiple print commands at the same time in the Console, instead of one at a time as was the case with the popup window shown in the video. The other change to note is the addition of a "\n" in the print block, as seen above. The "\n" tells RoboBlockly to start a new printing line at that point ("\n" standing for "newline").
Example 1: Solving Simple Mathematical Expressions
The example sets a variable to the sum of the square root of 225 and 5. Then it inputs that variable to a driveDistance block to drive the robot forward. Finally, it prints out the output as "Variable is __, which is the sum of sqrt(225) and 5."
Piano
Grid Lines:
Tics Lines:
Widthpx
Hash Lines:
Widthpx
Labels:
Fontpx
Trace Lines:
Robot 1:
Widthpx
Robot 2:
Widthpx
Robot 3:
Widthpx
Robot 4:
Widthpx
Grid Size:
SML
Simple View:
MinView:
Coord: x-axisy-axis
Grid Lines: x-axisy-axis
Grid:
12x12 inches
24x24 inches
36x36 inches
72x72 inches
96x96 inches
192x192 inches
1x1 inches
2x2 inches
Fraction:
xy-Range:
Quad:
1 Quadrant
4 Quadrants
1&4 Quadrants
Units:
US Customary
Metric
Ruler:
Label:
1Linkbot
0
S
M
L
Initial Position (x, y):
(,) in
Initial Angle:
degrees
Current Position (x,y)
(0, 0) in
Current Angle:
90 degrees
Wheel Radius:
2Linkbot
0
S
M
L
Initial Position (x, y):
(,) in
Initial Angle:
degrees
Current Position (x,y)
(0, 6) in
Current Angle:
0 degrees
Wheel Radius:
3Linkbot
0
S
M
L
Initial Position (x, y):
(,) in
Initial Angle:
degrees
Current Position (x,y)
(0, 12) in
Current Angle:
0 degrees
Wheel Radius:
4Linkbot
0
S
M
L
Initial Position (x, y):
(,) in
Initial Angle:
degrees
Current Position (x,y)
(0, 18) in
Current Angle:
0 degrees
Wheel Radius:
Hardware
LArduino
Workspace
Load
Save
Ch
Ch Shell
Console
Lock
roboblocklyL339ex1.ch
Time
Pre-Board Workspace
Blocks
Workspace
Load
Save
Ch
Post-Board Workspace
Blocks
Workspace
Load
Save
Ch
varvar31101111221291.574503.12641051101100110010236812612MULTIPLY84MULTIPLY8.42Hi Sam\n Good day!variabletexttext\nvariable\n13comment2xyLeft click on gridxyLeft click on gridxyLeft click on grid30505correct3verticalvariableFALSEvariablevarvar2var13variable1FALSE3variablevar13var2var13variable1FALSE3variablevar13var2varFFFF00#999999#a52a2a2#00ffff0.700#ffffff0.7010#00ff000.5002#ffffff0.7004#00ff000.50.03x axistime (s)x-1010x5x1centertext4544891000490054544300804400890101002*x+11186231100286880121268000545315005453150054518000201200020120452700068-60-2626601,2,312380100012512612Dog568imageDogimageimage568image90imagehorizontalimage10.713OUTPUT13HIGH1330100013OUTPUT13HIGH1330A013100010003131000100031313100010001398985A09100019544240099091500999A0LOWOUTPUT0010230255590434904#00FFFF#00FFFF40.55555345090LadybugM10010HelloHello2HmmHmm2Hello100femaleen#00FFFF0.50.52colorshighlow21C3HalfC31200115904349034500.50.52colorshighlow21590434904#A52A2A#A52A2A40.55555345090LadybugM10010HelloHello2HmmHmm2Hello100femaleen#A52A2A0.50.52colorshighlow21C3HalfC31200115904349034500.50.52colorshighlow21590434904#FFA500#FFA50040.55555345090LadybugM10010HelloHello2HmmHmm2Hello100femaleen#FFA5000.50.52colorshighlow21C3HalfC31200115904349034500.50.52colorshighlow21590434904#000000#00000040.55555345090LadybugM10010HelloHello2HmmHmm2Hello100femaleen#0000000.50.52colorshighlow21C3HalfC31200115904349034500.50.52colorshighlow21varvar31101111221291.574503.12641051101100110010236812612MULTIPLY84MULTIPLY8.42Hi Sam\n Good day!variabletexttext\nvariable\n13comment2xyLeft click on gridxyLeft click on gridxyLeft click on grid30505correct3verticalvariableFALSEvariablevarvar2var13variable1FALSE3variablevar13var2var13variable1FALSE3variablevar13var2varFFFF00#999999#a52a2a2#00ffff0.700#ffffff0.7010#00ff000.5002#ffffff0.7004#00ff000.50.03x axistime (s)x-1010x5x1centertext4544891000490054544300804400890101002*x+11186231100286880121268000545315005453150054518000201200020120452700068-60-2626601,2,312380100012512612Dog568imageDogimageimage568image90imagehorizontalimage10.713OUTPUT13HIGH1330100013OUTPUT13HIGH1330A013100010003131000100031313100010001398985A09100019544240099091500999A0LOWOUTPUT001023025555111190904#00FFFF#00FFFF41C3Half#00FFFF113LadybugMHello100femaleen111135555111190904#A52A2A#A52A2A41C3Half#A52A2A113LadybugMHello100femaleen111135555111190904#FFA500#FFA50041C3Half#FFA500113LadybugMHello100femaleen111135555111190904#000000#00000041C3Half#000000113LadybugMHello100femaleen1111355varvar31101111221291.574503.12641051101100110010236812612MULTIPLY84MULTIPLY8.42Hi Sam\n Good day!variabletexttext\nvariable\n13comment2xyLeft click on gridxyLeft click on gridxyLeft click on grid30505correct3verticalvariableFALSEvariablevarvar2var13variable1FALSE3variablevar13var2var13variable1FALSE3variablevar13var2varFFFF00#999999#a52a2a2#00ffff0.700#ffffff0.7010#00ff000.5002#ffffff0.7004#00ff000.50.03x axistime (s)x-1010x5x1centertext4544891000490054544300804400890101002*x+1661812236600286880121268000545315005453150054518000201200020120452700068-60-2626601,2,312380100012512612Dog568imageDogimageimage568image90imagehorizontalimage10.713OUTPUT13HIGH1330100013OUTPUT13HIGH1330A013100010003131000100031313100010001398985A09100019544240099091500999A0LOWOUTPUT0010230255000909020909090909090909090909090000909020909090909090909090909090000909020909090909090909090909090000909020909090909090909090909090varvar31101111221291.574503.12641051101100110010236812612MULTIPLY84MULTIPLY8.42Hi Sam\n Good day!variabletexttext\nvariable\n13comment2xyLeft click on gridxyLeft click on gridxyLeft click on grid30505correct3verticalvariableFALSEvariablevarvar2var13variable1FALSE3variablevar13var2var13variable1FALSE3variablevar13var2varFFFF00#999999#a52a2a2#00ffff0.700#ffffff0.7010#00ff000.5002#ffffff0.7004#00ff000.50.03x axistime (s)x-1010x5x1centertext4544891000490054544300804400890101002*x+11186231100286880121268000545315005453150054518000201200020120452700068-60-2626601,2,312380100012512612Dog568imageDogimageimage568image90imagehorizontalimage10.713OUTPUT13HIGH1330100013OUTPUT13HIGH1330A013100010003131000100031313100010001398985A09100019544240099091500999A0LOWOUTPUT001023025513OUTPUT13HIGH1330100013OUTPUT13HIGH1330A013100010003131000100031313100010001398985A09100019544240099091500999A0LOWOUTPUT001023025513OUTPUT13HIGH1330100013OUTPUT13HIGH1330A013100010003131000100031313100010001398985A09100019544240099091500999A0LOWOUTPUT001023025513OUTPUT13HIGH1330100013OUTPUT13HIGH1330A013100010003131000100031313100010001398985A09100019544240099091500999A0LOWOUTPUT001023025513OUTPUT13HIGH1330100013OUTPUT13HIGH1330A013100010003131000100031313100010001398985A09100019544240099091500999A0LOWOUTPUT0010230255varvar31101111221291.574503.12641051101100110010236812612MULTIPLY84MULTIPLY8.42Hi Sam\n Good day!variabletexttext\nvariable\n13comment2FFFF00#999999#a52a2a2#00ffff0.700#ffffff0.7010#00ff000.5002#ffffff0.7004#00ff000.50.03x axistime (s)x-1010x5x1centertext4544891000490054544300804400890101002*x+11186231100286880121268000545315005453150054518000201200020120452700068-60-2626601,2,31238010001251212Dog568imageDogimageimage568image90imagehorizontalimage0.715LadybugM100#00FFFF90010LadybugM11x11x36x365x axistime (s)x-1010x5x1varvar31101111221291.574503.12641051101100110010236812612MULTIPLY84MULTIPLY8.42Hi Sam\n Good day!variabletexttext\nvariable\n13comment2xyLeft click on gridxyLeft click on gridxyLeft click on grid30505correct3verticalvariableFALSEvariablevarvar2var13variable1FALSE3variablevar13var2var13variable1FALSE3variablevar13var2varFFFF00#999999#a52a2a2#00ffff0.700#ffffff0.7010#00ff000.5002#ffffff0.7004#00ff000.50.03x axistime (s)x-1010x5x1centertext4544891000490054544300804400890101002*x+11186231100286880121268000545315005453150054518000201200020120452700068-60-2626601,2,312380100012512612Dog568imageDogimageimage568image90imagehorizontalimage0.715LadybugM100#00FFFF90010LadybugM11x11x36x365x axistime (s)x-1010variableADDROOT2255variablevariable, which is the sum of sqrt(225) and 5\n