Telling Time

Linkbot Image Mindstorm Image Cursor Image
0x126-6-12y126-6-12
Grid:
Tics Lines:
Width px
Hash Lines:
Width px
Labels:
Font px
Trace Lines:
Robot 1:
Width px
Robot 2:
Width px
Robot 3:
Width px
Robot 4:
Width px
Axes: x-axis y-axis Show Grid
Grid: 24x24 inches 36x36 inches 72x72 inches
96x96 inches 192x192 inches
Quad: 4 quadrants 1 quadrant Hardware
Units: US Customary Metric
Background: Background Image

Robot 1

Linkbot
Mindstorm
Initial Position:
( in, in)
Initial Angle:
deg
Current Position: (0 in, 0 in)
Current Angle: 0 deg
Wheel Radius:
Track Width:
in

Robot 2

Linkbot
Mindstorm
Initial Position:
( in, in)
Initial Angle:
deg
Current Position: (0 in, 4 in)
Current Angle: 0 deg
Wheel Radius:
Track Width:
in

Robot 3

Linkbot
Mindstorm
Initial Position:
( in, in)
Initial Angle:
deg
Current Position: (0 in, 8 in)
Current Angle: 0 deg
Wheel Radius:
Track Width:
in

Robot 4

Linkbot
Mindstorm
Initial Position:
( in, in)
Initial Angle:
deg
Current Position: (0 in, 12 in)
Current Angle: 0 deg
Wheel Radius:
Track Width:
in

Learning the Clock (Minute Hand)
Problem Statement:
Run the code and input values into the prompt to watch a clock in action. Read the final position of the clock. 
/* Code generated by RoboBlockly v2.0 */
/* Problem Statement: 
    Run the code and input a value to watch a clock in action. */
#include <chplot.h>
double hour;
double minute;
CPlot plot;

// Describe this function...
void Winding_hour() {
  double i;
  double i_inc = 0.05;
  if (0 > hour) {
    i_inc = -i_inc;
  }
  i = 0;
  while(i_inc >= 0 ? i <= hour : i >= hour) {
    //plot.backgroundImage("./Background.png");
    plot.strokeColor("black");
    plot.line(0, 0, 0, 7.2);
    plot.strokeColor("red");
    plot.line(0, 0, 6 * cos(deg2rad((90 - i * 30))), 6 * sin(deg2rad((90 - i * 30))));
    delaySeconds(0.01);
    i += i_inc;
  }
  //plot.backgroundImage("./Background.png");
  plot.strokeColor("black");
  plot.line(0, 0, 0, 7.2);
  plot.strokeColor("red");
  plot.line(0, 0, round((6 * cos(deg2rad((90 - hour * 30))))), round((6 * sin(deg2rad((90 - hour * 30))))));
}

// Describe this function...
void Winding_minute() {
  double angleH;
  double j;
  angleH = 90 - hour * 30;
  double j_inc = 0.1;
  if (0 > minute) {
    j_inc = -j_inc;
  }
  j = 0;
  while(j_inc >= 0 ? j <= minute : j >= minute) {
    //plot.backgroundImage("./Background.png");
    plot.strokeColor("red");
    plot.line(0, 0, 6 * cos(deg2rad((angleH - j * 0.5))), 6 * sin(deg2rad((angleH - j * 0.5))));
    plot.strokeColor("black");
    plot.line(0, 0, 7.2 * cos(deg2rad((90 - j * 6))), 7.2 * sin(deg2rad((90 - j * 6))));
    delaySeconds(0.001);
    j += j_inc;
  }
}

// Sample: It's 3:10 . Enter 3 for hour and 10 for minute
plot.strokeWidth(6);
plot.strokeColor("black");
plot.line(0, 0, 0, 7.2);
plot.strokeColor("red");
plot.line(0, 0, 0, 6);
delaySeconds(0.1);
hour = 3;
Winding_hour();
minute = 10;
Winding_minute();

plot.label(PLOT_AXIS_XY, "");
plot.grid(PLOT_OFF);
plot.tics(PLOT_AXIS_XY, PLOT_OFF);
plot.axis(PLOT_AXIS_XY, PLOT_OFF);
plot.axisRange(PLOT_AXIS_XY, -12, 12);
plot.ticsRange(PLOT_AXIS_XY, 2);
plot.sizeRatio(1);
plot.plotting();
Blocks Save Blocks Load Blocks Show Ch Save Ch Workspace
Problem Statement:
Run the code and input values into the prompt to watch a clock in action. Read the final position of the clock. 

		
Rubbish bin
Time