The function returns the specified parameter for the specified number card detected. Parameters (Integer Value):
- 1 for the X position
- 2 for the Y position
- 3 for width
- 4 for height
- 5 for confidence
Function Definition: getnumberdetail(card_number = 1, parameter_value = 1)
The function returns the specified parameter for the specified number card detected. Parameters (Integer Value):
Name | Type | Description | Expected Values | Default Value |
---|---|---|---|---|
card_number | int | The card number which you want to analyse. | 0-9 | 1 |
parameter_value | int | Parameter: 1 for the X position 2 for the Y position 3 for width 4 for height 5 for confidence | 1, 2, 3, 4 or 5 | 1 |
sprite = Sprite('Tobi')
pen = Pen()
pen.clear()
while True:
if (sprite.iskeypressed("space")):
sprite.setx(sprite.mousex())
sprite.sety(sprite.mousey())
pen.stamp()
sprite = Sprite('Beetle')
sprite.setdirection(90)
sprite.gotoxy(0, 0)
while True:
if sprite.iskeypressed('up arrow'):
sprite.move(3)
if sprite.iskeypressed('down arrow'):
sprite.move(-3)
if sprite.iskeypressed('left arrow'):
sprite.left(3)
if sprite.iskeypressed('right arrow'):
sprite.right(3)
sprite = Sprite('Ball')
while True:
if sprite.iskeypressed('up arrow'):
sprite.changey(3)
if sprite.iskeypressed('down arrow'):
sprite.changey(-3)
if sprite.iskeypressed('left arrow'):
sprite.changex(-3)
if sprite.iskeypressed('right arrow'):
sprite.changex(3)
sprite = Sprite('Arrow1')
sprite.gotoxy(0, 0)
sprite.setsize(300)
while True:
if sprite.iskeypressed("left arrow"):
sprite.left(3)
if sprite.iskeypressed("right arrow"):
sprite.right(3)
sprite.say("Direction is " + str(sprite.direction()))
sprite = Sprite('Tobi')
while True:
if (sprite.iskeypressed("space")):
sprite.goto("_mouse_")
sprite = Sprite('Tobi')
import time
sprite.setrotationstyle('left-right')
while True:
sprite.move(5)
sprite.bounceonedge()
sprite.switchcostume("Tobi walking 1")
time.sleep(0.1)
sprite.move(5)
sprite.bounceonedge()
sprite.switchcostume("Tobi walking 2")
time.sleep(0.1)
sprite = Sprite('Tobi')
while True:
sprite.pointto()
sprite.move(3)
sprite = Sprite('Ball')
import time
import random
sprite.setx(random.randrange(-200, 200))
sprite.sety(random.randrange(-100, 140))
gravity = -2
xpos = sprite.x()
ypos = sprite.y()
dx = random.randrange(-50, 50)
dy = random.randrange(-25, 25)
while True:
dy = dy + gravity
dx = dx * 0.98
dy = dy * 0.98
xpos = xpos + dx
ypos = ypos + dy
if ypos < -160:
dy = -dy
ypos = -160
if ypos > 130:
dy = -dy
ypos = 130
if xpos < -220:
dx = -dx
xpos = -220
if xpos > 220:
dx = -dx
xpos = 220
sprite.gotoxy(xpos, ypos)
time.sleep(0.01)
sprite = Sprite('Tobi')
import time
effect = "COLOR"
# effect = "FISHEYE"
# effect = "WHIRL"
# effect = "PIXELATE"
# effect = "MOSAIC"
# effect = "BRIGHTNESS"
# effect = "GHOST"
sprite.gotoxy(0, 0)
sprite.setsize(200)
sprite.cleareffects()
sprite.seteffect(effect, 0)
while True:
for i in range(10):
sprite.changeeffect(effect, 5)
time.sleep(0.1)
for i in range(10):
sprite.changeeffect(effect, -5)
time.sleep(0.1)
sprite = Sprite('Tobi')
import time
sprite.gotoxy(0, 0)
sprite.setsize(200)
while True:
sprite.show()
time.sleep(1)
sprite.hide()
time.sleep(1)
sprite = Sprite('Tobi')
import time
sprite.say("Saying for 2 seconds", 2)
sprite.say("Saying forever")
time.sleep(2)
sprite.think("Thinking for 2 seconds", 2)
sprite.think("Thinking forever")
sprite = Sprite('Tobi')
sprite.gotoxy(0, 0)
sprite.setsize(200)
sprite.switchcostume("Tobi")
while True:
sprite.say(sprite.costume("name"), 1)
sprite.nextcostume()
sprite = Sprite('Tobi')
sprite.input("Which table you want to recite")
number = int(sprite.answer())
for i in range(1, 10):
sprite.say(str(number) + " x " + str(i) + " = " + str(number*i), 1)
sprite = Sprite('Tobi')
import time
sprite.gotoxy(0, 0)
sprite.setsize(100)
while True:
for i in range(10):
sprite.changesize(sprite.size()/10)
time.sleep(0.01)
for i in range(10):
sprite.changesize(- sprite.size()/10)
time.sleep(0.01)
An IR sensor consists of 2 LEDs: one which transmits the IR light and one which receives the IR light. When the IR rays are transmitted, they bounce from the nearest surface and get back to the receiver LED. That’s how an IR sensor detects an object.
But to detect colors, we depend on the number of rays the surface reflects:
We can get the sensor values in PictoBlox and based on that value we can estimate whether the surface is black or white.
We will call the threshold value above which the sensor detects the black line. If the sensor value is less than the threshold, it means that the sensor hasn’t detected the line yet.
Now, run the script by clicking the green flag and bringing the black line of the track close to the IR sensor. One of the following three conditions will happen:
Now modify the script to add the detection value for the right IR sensor.