Approved content
The content below is provided by a partner.
This library provides a Microsoft Makecode package for the Joy-IT Joy-Car. See here for more details.
You have to initialize the Joy-Car with your mainboard revision. You can find your revision on the backside of your mainboard. Older revisions than 1.2 have no revision number on the back. This will ensure that the repository is compatible with all revisions of the mainboard.
You have to initialize the microcontroller with which you use the Joy-Car. Therefore, you can use this library with the micro:bit and the Calliope.
The smart collision detection is only available if you have mounted the ultrasonic sensor in the top position, in combination with the servo motor. In this case, the ultrasonic sensor checks for obstacles in all front directions and returns if an obstacle is close or not.
Return value | Direction |
---|---|
0 | nothing |
1 | left |
2 | middle |
3 | right |
You can drive the Joy-Car forwards or backwards by using the drive(...)
block. Within this block you specify the direction aswell as the speed in percent from 0 to 100.
Both motors will be driven in the selected direction with the selected speed.
You can use the turn(...)
block to drive forwards or backwards in combination with turning left or right.
You can specify the orientation (forward, reverse), direction (left, right) aswell as the speed (0 - 100%) and the size of the curve-radius (0-5).
The larger the curve-radius the wider the turn will be (0 = very sharp turn, 5 = very wide turn).
Use stop(...)
to either brake with an intense stop or with declining speed.
You can set the angle (0 - 180) of the two optional servos which are connected to pin P1 and P13 of the micro:bit by using servo(...)
.
Both motors will probably, due to manufacturing tolerances, not spin at the very same speed. This can result in driving small curves when you intend to drive straight forward or backward. In this case you can set a global bias with bias(...)
which will slow down the speed-signal for the specific motor. This shall compensate any speed differences.
You can also send direct PWM-Signals to all four channels (Channel 2, Channel 3, Channel 4 & Channel 5) of the motor-controller by using drivePwm(...)
.
Turn on/off the headlights (white light from the two front LED modules) by using light(...)
.
Turn on/off the brakelight (red light from the two rear LED modules) by using brake(...)
.
Turn on/off the indicators (flashing orange light from the front and rear LED module on the left or right side) for a specific side with indicator(...)
.
Turn on/off the hazard lights (flashing orange light from all LED modules) with hazardlights(...)
.
Turn on/off the reverse lights (white light from the rear LED modules) with reversinglight(...)
.
Check the ultrasonic sensor with sonar()
. The return value is the distance to the closest object measured from the sensor. The sensor is connected to the pins P12 (echo) and P8 (trigger) of the micro:bit.
Check the linefinder sensors with linefinder(...)
. The function returns true if a line was detected. The sensors are connected to channel 3, 4 & 5 of the IO-Expander.
Check the obstacle sensors with obstacleavoidance(...)
. The function returns true if an obstacle was detected. The sensors are connected to channel 1 & 2 of the IO-Expander.
Check the speed sensors with speed(...)
. The function returns true if the light is interrupted by the perforated disc on the motor.
Play predefined sound with buzzer for a certain amount of microseconds with buzzer_sound()
.
Play predefined melodies with the buzzer with buzzer_melody()
. You can also specifiy repeat options.
Read the current battery voltage from the ADC on the AnalogPin2 by using readAdc()
.
Read values from IO expander with readIOExpander()
.
Write values on the free pins from the IO expander with writeIOExpander()
. You can write on pin 7 or with revision 1.3 or newer also on pin 0 and pin 1.
MIT