'''
To adjust the color settings, it is best to uncomment
one print line to see which yuv values to bound for that
specific color.
'''
from Myro import *
init("com3")

setPictureSize("small")
autoCamera()


'''
#chase blue setting
ylow = 0
yhigh = 255
ulow = 134
uhigh = 142
vlow = 114
vhigh = 121
xsum = 0
ysum = 0
num = 0
'''
#chase red setting
ylow = 0
yhigh = 255
ulow = 122
uhigh = 134
vlow = 143
vhigh = 183
xsum = 0
ysum = 0
num = 0



c = 0
while True:
    num = 1
    xsum = 0
    ysum = 0
    p = takePicture()


    show(p)
    for pixel in getPixels(p):
        color = getColor(pixel)
        r = getRed(pixel)
        g = getGreen(pixel)
        b = getBlue(pixel)


        y, u, v = rgb2yuv(r,g,b)
        #this is the color of interest, highlighted in red
        if u >= ulow and u <= uhigh and v >= vlow and v <= vhigh:
            num = num + 1
            xsum += getX(pixel)
            ysum += getY(pixel)
            setRed(pixel, 200)
            #print(rgb2yuv(r,g,b))#
        else: #colors that are not of interest, highlighted in blue
            '''
            c += 1
            if (c % 25 == 0):
                print(rgb2yuv(r,g,b))#
            '''
            #print(rgb2yuv(r,g,b))
            setBlue(pixel, 200)

    print("The number of pixels of the color of interest: ", num)
    xavg = xsum / num
    print("The average pixel x position of the color of interest: ", xavg)
    yavg = ysum / num
    #print(yavg)
    continue
    if num > 1500: #there are enough pixels of the color of interest
        if xavg < 150:#the object is to the left
            turnBy(10)
        elif xavg > 300:#the object is to the right
            turnBy(-10)
        else:#the object is ahead
            forward(1,1)
            beep(0.1, 600)
    else:#no object of interest is detected
        beep(0.1, 500, 600)


@@ -122,16 +122,122 @@
 ic color
+ and uncomment the %22continue%22 line to stop movement%0Aso that you can focus on picking the color of interest
 .%0A'''%0Afr
@@ -262,14 +262,8 @@
 nit(
-%22com3%22
 )%0A%0As
@@ -300,19 +300,16 @@
 era()%0A%0A%0A
-'''
 %0A#chase 
@@ -530,16 +530,19 @@
 num = 0%0A
+'''
 %0A%0A%0Ac = 0
@@ -1551,24 +1551,25 @@
 vg)%0A    
+#
 continue
 %0A    if 
@@ -1560,16 +1560,55 @@
 continue
+ #uncomment this line to prevent motion
 %0A    if 
@@ -1614,17 +1614,17 @@
  num %3E 1
-5
+0
 00: #the

Update blob_follow_red_or_blue.py