Zeitmessung

http://sites.prenninger.com/arduino-uno-r3/zeitmessung

http://www.linksammlung.info/

http://www.schaltungen.at/

                                                                                        Wels, am 2015-01-06

BITTE nützen Sie doch rechts OBEN das Suchfeld  [                                                              ] [ Diese Site durchsuchen]

DIN A3 oder DIN A4 quer ausdrucken
*******************************************************************************I**
DIN A4  ausdrucken   siehe
********************************************************I*
~015_b_PrennIng-a_arduino.uno.r3-zeitmessung (xx Seiten)_1a.pdf


                             OpenProcessing
http://www.openprocessing.org/books/


Milliseconds.

A millisecond is 1/1000 of a second. Processing keeps track of the number of milliseconds a program has run. By modifying this number with the modulo(%) operator, different patterns in time are created.

 
float scale;

void setup() {
  size(640, 360);
  noStroke();
  scale = width/20;
}

void draw() { 
  for (int i = 0; i < scale; i++) {
    colorMode(RGB, (i+1) * scale * 10);
    fill(millis()%((i+1) * scale * 10));
    rect(i*scale, 0, scale, height);
  }
}

 
https://processing.org/examples/milliseconds.html






Analog-Uhr mit Sekundenzeiger

Clock.

The current time can be read with the second(), minute(), and hour() functions. In this example, sin() and cos() values are used to set the position of the hands.

int cx, cy;
float secondsRadius;
float minutesRadius;
float hoursRadius;
float clockDiameter;

void setup() {
  size(640, 360);
  stroke(255);
  
  int radius = min(width, height) / 2;
  secondsRadius = radius * 0.72;
  minutesRadius = radius * 0.60;
  hoursRadius = radius * 0.50;
  clockDiameter = radius * 1.8;
  
  cx = width / 2;
  cy = height / 2;
}

void draw() {
  background(0);
  
  // Draw the clock background
  fill(80);
  noStroke();
  ellipse(cx, cy, clockDiameter, clockDiameter);
  
  // Angles for sin() and cos() start at 3 o'clock;
  // subtract HALF_PI to make them start at the top
  float s = map(second(), 0, 60, 0, TWO_PI) - HALF_PI;
  float m = map(minute() + norm(second(), 0, 60), 0, 60, 0, TWO_PI) - HALF_PI; 
  float h = map(hour() + norm(minute(), 0, 60), 0, 24, 0, TWO_PI * 2) - HALF_PI;
  
  // Draw the hands of the clock
  stroke(255);
  strokeWeight(1);
  line(cx, cy, cx + cos(s) * secondsRadius, cy + sin(s) * secondsRadius);
  strokeWeight(2);
  line(cx, cy, cx + cos(m) * minutesRadius, cy + sin(m) * minutesRadius);
  strokeWeight(4);
  line(cx, cy, cx + cos(h) * hoursRadius, cy + sin(h) * hoursRadius);
  
  // Draw the minute ticks
  strokeWeight(2);
  beginShape(POINTS);
  for (int a = 0; a < 360; a+=6) {
    float angle = radians(a);
    float x = cx + cos(angle) * secondsRadius;
    float y = cy + sin(angle) * secondsRadius;
    vertex(x, y);
  }
  endShape();
}

 
https://processing.org/examples/clock.html




Digital-Uhr

Simple Digital Clock with OOP- OpenProcessing



DigitalClock digitalClock;
 
void setup() {
  size(240, 240);
  digitalClock = new DigitalClock(40, width/2, height/2+15);
}
 
void draw() {
  background(204);
  digitalClock.getTime();
  digitalClock.display();
}
 
class DigitalClock extends Clock {
  int fontSize;
  float x, y;
   
  DigitalClock(int _fontSize, float _x, float _y) {
    fontSize = _fontSize;
    x = _x;
    y = _y;
  }
   
  void getTime() {
    super.getTime();
  }
   
  void display() {
    textSize(fontSize);
    textAlign(CENTER);
    text (h + ":" + nf(m, 2) + ":" + nf(s, 2), x, y);
  }
}
 
class Clock {
  int h, m, s;
  Clock() {
  }
   
  void getTime() {
    h = hour();
    m = minute();
    s = second();
  }
}


http://www.openprocessing.org/sketch/16037






Digital-Uhr


PFont font;
void setup() {
  size(300, 300);
 
  font = loadFont("ArialMT-48.vlw");
  textFont(font);
}
 
void draw() {
  background(0);
  fill(0);
  stroke(160);
  strokeWeight(5);
  rect(15,100,277,100);
  pushMatrix();
int a = minute();
int b = minute();
int c = hour();
int d = hour ();
 
  if (a%10 == 1) {
    textSize(90);
    fill (255, 0, 0);
    text(1, 240, 180);
  }
  else if (a%10 == 2) {
    textSize(90);
    fill(255, 0, 0);
    text(2, 240, 180);
  }
  else if (a%10 == 3) {
    textSize(90);
    fill(255, 0, 0);
    text(3, 240, 180);
  }
  else if (a%10 == 4) {
    textSize(90);
    fill(255, 0, 0);
    text(4, 240, 180);
  }
  else if (a%10 == 5) {
    textSize(90);
    fill(255, 0, 0);
    text(5, 240, 180);
  }
  else if (a%10 == 6) {
    textSize(90);
    fill(255, 0, 0);
    text(6, 240, 180);
  }
  else if (a%10 == 7) {
    textSize(90);
    fill(255, 0, 0);
    text(7, 240, 180);
  }
  else if (a%10 == 8) {
    textSize(90);
    fill(255, 0, 0);
    text(8, 240, 180);
  }
  else if (a%10 == 9) {
    textSize(90);
    fill(255, 0, 0);
    text(9, 240, 180);
  }
  else if (a%10 == 0) {
    textSize(90);
    fill(255, 0, 0);
    text(0, 240, 180);
  }
  popMatrix();
 
  pushMatrix();
 
  if (b/10 < 2 && b/10 > 0) {
    textSize(90);
    fill (255, 0, 0);
    text(1, 180, 180);
  }
  else if (b/10 < 3 && b/10 > 1) {
    textSize(90);
    fill(255, 0, 0);
    text(2, 180, 180);
  }
  else if (b/10 < 4 && b/10 > 2) {
    textSize(90);
    fill(255, 0, 0);
    text(3, 180, 180);
  }
  else if (b/10 < 5 && b/10 > 3) {
    textSize(90);
    fill(255, 0, 0);
    text(4, 180, 180);
  }
  else if (b/10 < 6 && b/10 > 4) {
    textSize(90);
    fill(255, 0, 0);
    text(5, 180, 180);
  }
   
  else if (b/10 < 1 && b/10 > -1) {
    textSize(90);
    fill(255, 0, 0);
    text(0, 180, 180);
  }
println(b/10);
  popMatrix();
 
  pushMatrix();
 
  if (hour()/10 < 2 && b/10 > 0) {
    textSize(90);
    fill (255, 0, 0);
    text(1, 20, 180);
  }
  else if (hour()/10 < 3 && b/10 > 1) {
    textSize(90);
    fill(255, 0, 0);
    text(2, 20, 180);
  }
  else if (hour()/10 < 1 && b/10 > -1) {
    textSize(90);
    fill(255, 0, 0);
    text(0, 20, 180);
  }
 
  popMatrix();
 
  pushMatrix();
 
  if (hour() % 10==1) {
    textSize(90);
    fill (255, 0, 0);
    text(1, 80, 180);
  }
  else if (hour()%10==2) {
    textSize(90);
    fill(255, 0, 0);
    text(2, 80, 180);
  }
  else if (hour()%10==3) {
    textSize(90);
    fill(255, 0, 0);
    text(3, 80, 180);
  }
 
  else if (hour()%10==4) {
    textSize(90);
    fill(255, 0, 0);
    text(4, 80, 180);
  }
 
  else if (hour()%10==5) {
    textSize(90);
    fill(255, 0, 0);
    text(5, 80, 180);
  }
 
  else if (hour()%10==6) {
    textSize(90);
    fill(255, 0, 0);
    text(6, 80, 180);
  }
 
  else if (hour()%10==7) {
    textSize(90);
    fill(255, 0, 0);
    text(7, 80, 180);
  }
 
 
  else if (hour()%10==8) {
    textSize(90);
    fill(255, 0, 0);
    text(8, 80, 180);
  }
 
  else if (hour()%10==9) {
    textSize(90);
    fill(255, 0, 0);
    text(9, 80, 180);
  }
 
  else if (hour()%10==0) {
    textSize(90);
    fill(255, 0, 0);
    text(0, 80, 180);
  }
  popMatrix();
 
 
 
  boolean e = false;
  for (int i = 1; i<=second(); i++) {
    if (i % 2 ==0|| i == 0) {
      e=true;
    }
    else
    {
      e = false;
    }
  //  println(b);
 
    if (e==true) {
      noStroke();
      fill (255, 0, 0);
      rect(152, 130, 10, 10);
      rect(152, 150, 10, 10);
    }
    else
    {
      noStroke();
      fill (0, 0, 0);
      rect(152, 130, 10, 10);
      rect(152, 150, 10, 10);
    }
  }
}



http://www.openprocessing.org/classroom/3347





DIN A4  ausdrucken
********************************************************I*
Impressum: Fritz Prenninger, Haidestr. 11A, A-4600 Wels, Ober-Österreich, mailto:schaltungen@schaltungen.at
ENDE
a




a
Comments