unit 2 1.2

function setup() {
  createCanvas(600, 120);
}

function draw() {
  var redlight = 'white'
  var yellowlight = 'white'
  var greenlight = 'white'
  background(220);
   rectMode(CENTER);
  fill(140)
  rect(300,60,50,100)

  if(mouseY>90){
    greenlight='green'
  }
  else if(mouseY>55){
    yellowlight = 'yellow'
  }
  else{
    redlight='red'
  }
  
  fill(redlight)
  ellipse(300,30,20,20)
  fill(yellowlight)
  ellipse(300,60,20,20)
  fill(greenlight)
  ellipse(300,90,20,20) 
}

https://preview.p5js.org/nicepelican061/present/JVeDDrucs