找回密码
 马上注册

QQ登录

只需一步,快速开始

查看: 4095|回复: 3

robot C 电机返回度数。控制sindegress的正弦图

[复制链接]
发表于 2017-10-15 09:18:58 | 显示全部楼层 |阅读模式

task main()
{
        int a[177],i=0,ss=50;
        float x=0,y;
        setMotorBrakeMode(motorB,motorCoast);
        while(x<10000)
        {

                ss=getMotorEncoder(motorB)/10;
                if(ss>40)ss=40;
                if(ss<-40)ss=-40;
                displayCenteredBigTextLine(0,"ss=%d  mo=%d",ss,getMotorEncoder(motorB));
                drawLine(0,62,176,62);
                y=sinDegrees(x*8)*ss+62;
       
                if(x<176)
                {
                a[x]=y;

                //displayCenteredBigTextLine(2,"%d %f",i,x);
                for(int t=0;t<3;t++)
                {
                        setPixel(x,y+t);
                }
                }else{

                i=176;

                 for(int j=0;j<i;j++)
                 {
                   for(int t=0;t<3;t++)
                        {
                        clearPixel(j,a[j]+t);

                        }
                        for(int t=0;t<3;t++)
                        {
                        setPixel(j,a[j+1]+t);

                        }


        a[j]=a[j+1];
                 }
                        a[176]=y;

                }


                x+=1;

                sleep(10);
        }

sleep(2000);
}

微信图片_20171015091621.jpg
微信图片_20171015091625.jpg
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
 楼主| 发表于 2017-10-15 09:21:05 | 显示全部楼层
数组好像,最大只有255.不然定的多点 图就顺了。
好像超无用的东西。
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

 楼主| 发表于 2017-10-15 13:29:42 | 显示全部楼层
task drawtable()
{
        int y=0,i=0,a[10];

        while(true)
        {
        y=getMotorRPM(motorB);
        if(i<10)
        {
                fillRect(i*18+1,y,i*18+12,0);

                a[i]=y;
                i++;
        }else
        {
                i=10;
                for(int j=0;j<i;j++)
                {
                        eraseRect(j*18+1,a[j],j*18+12,0);
                        fillRect(j*18+1,a[j+1],j*18+12,0);
                        a[j]=a[j+1];
                }
                eraseRect(9*18+1,a[9],9*18+12,0);
                fillRect(9*18+1,y,9*18+12,0);
                a[9]=y;
                sleep(800);
        }
}

}
task main()
{
        startTask(drawtable);
        setMotorBrakeMode(motorB,motorCoast);
        setMotorBrakeMode(motorC,motorCoast);
        setMotorSync(motorB,motorC,0,40);
        sleep(10000);
        stopTask(drawtable);
}
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2017-10-17 20:05:42 | 显示全部楼层
好屌好屌!!!!就是不会用robotc
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|中文乐高 ( 桂ICP备13001575号-7 )

GMT+8, 2024-6-1 21:20 , Processed in 0.224470 second(s), 22 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表