Brain Sensing#
Reset Timer#
The Reset Timer block is used to reset the V5 Brain’s timer.
reset timer
The Brain’s timer begins at the beginning of each project. The reset timer block is used to reset the timer back to 0 seconds.
In this example, the Brain will print the current time after waiting 2 seconds before resetting its timer.
when started :: hat events
wait (2) seconds
print (timer in seconds) on [Brain v] ◀ and set cursor to next row
reset timer
Timer Value#
The Timer Value block is used to report the value of the V5 Brain’s timer in seconds.
timer in seconds
The timer starts at 0 seconds when the program starts, and reports the timer’s value as a decimal value.
In this example, the Brain will print the current time after waiting 2 seconds before resetting its timer.
when started :: hat events
wait (2) seconds
print (timer in seconds) on [Brain v] ◀ and set cursor to next row
reset timer
Cursor Column#
The Cursor Column block is used to report the column number of the V5 Brain’s screen cursor location.
cursor column
The Cursor Column block will report a value from 1-80 and will start on column 1 at the start of a project.
In this example, the Brain will move the cursor to (3, 7) and then print the current column (7) on the Brain’s screen.
when started :: hat events
set cursor to row (3) column (7) on Brain
print (cursor column) on [Brain v] ◀ and set cursor to next row
Cursor Row#
The Cursor Row block is used to report the row number of the V5 Brain’s screen cursor location.
cursor row
The Cursor Column block will report a value from 1-9 and will start on row 1 at the start of a project.
In this example, the Brain will move the cursor to (3, 7) and then print the current row (3) on the Brain’s screen.
when started :: hat events
set cursor to row (3) column (7) on Brain
print (cursor row) on [Brain v] ◀ and set cursor to next row
Brain Screen Pressed#
The Brain Screen Pressed block is used to report if the V5 Brain’s touchscreen is currently being pressed.
<screen pressed?>
The Brain Screen Pressed block reports True
when the V5 Brain’s touchscreen is being pressed.
The Brain Screen Pressed block reports False
when the V5 Brain’s touchscreen is not being pressed.
In this example, a message will be printed on the V5 Brain’s screen the first time the touchscreen is pressed.
when started :: hat events
[Don't do anything until the touchscreen is pressed.]
wait until <screen pressed?>
print [Touchscreen was pressed!] on [Brain v] ◀ and set cursor to next row
Screen Position#
The Screen Position block is used to report the location of the last detected touch on the V5 Brain’s touchscreen.
(screen [x v] position)
Choose what axis to report: x or y.
In this example, a circle will be printed on the V5 Brain’s screen wherever the touchscreen is pressed.
when started :: hat events
[Keep checking for when the touchscreen is pressed indefinitely.]
forever
if <screen pressed?> then
[Draw a circle at the exact X and Y coordinate where it was pressed.]
draw circle (screen [x v] position) (screen [y v] position :: #5cb0d6) (20) on Brain
end
Battery Voltage#
The Battery Voltage block is used to report the voltage of the V5 Brain’s battery.
(battery voltage in volts)
The Battery Voltage block reports a range from 10.0 volts to 14.4 volts.
In this example, the Brain will print its current battery voltage on the Brain’s screen.
when started :: hat events
print (battery voltage in volts) on [Brain v] ◀ and set cursor to next row
Battery Current#
The Battery Current block is used to report the current of the V5 Brain’s battery.
(battery current in amps)
The Battery Current block reports a range from 0.0 amps to 20.0 amps.
In this example, the Brain will print its current battery current on the Brain’s screen.
when started :: hat events
print (battery current in amps) on [Brain v] ◀ and set cursor to next row
Battery Capacity#
The Battery Capacity block is used to report the charge level of the V5 Brain’s battery.
(battery capacity in %)
The Battery Capacity block reports a range from 0% to 100%.
In this example, the Brain will print its current battery charge on the Brain’s screen.
when started :: hat events
print (battery capacity in %) on [Brain v] ◀ and set cursor to next row