Raspberry Pi Pico weather display (MicroPython)
Your first MicroPython project: temperature and humidity on an OLED.
Shop by category
Shop all componentsOn an FPGA you describe circuits, not programs. This design divides the Basys 3's 100 MHz clock to 100 Hz, counts hundredths and seconds in BCD and multiplexes the four-digit seven-segment display at about 1 kHz. The centre button starts and stops, the up button resets. Pin locations come from the Digilent Basys 3 master XDC file.
Tick anything you already have and the total updates.
Artix-7 FPGA trainer board with display and buttons
Follow the colours: red is power, dark grey is ground, blue is a signal.
Micro-USB from the computer powers and programs the board.
stopwatch.vmodule stopwatch(input clk, input btnC, input btnU, output reg [6:0] seg, output dp, output reg [3:0] an);
// 100 Hz tick from 100 MHz
reg [19:0] div = 0; wire tick = (div == 999_999);
always @(posedge clk) div <= tick ? 0 : div + 1;
// debounced start/stop toggle
reg [1:0] sync = 0; reg [19:0] cnt = 0; reg stable = 0, run = 0, prev = 0;
always @(posedge clk) begin
sync <= {sync[0], btnC};
if (sync[1] != stable) begin cnt <= cnt + 1; if (&cnt) stable <= sync[1]; end else cnt <= 0;
prev <= stable;
if (stable & ~prev) run <= ~run;
end
// BCD digits: d3 d2 = seconds, d1 d0 = hundredths
reg [3:0] d0 = 0, d1 = 0, d2 = 0, d3 = 0;
always @(posedge clk) begin
if (btnU) begin d0 <= 0; d1 <= 0; d2 <= 0; d3 <= 0; end
else if (run & tick) begin
if (d0 != 9) d0 <= d0 + 1; else begin d0 <= 0;
if (d1 != 9) d1 <= d1 + 1; else begin d1 <= 0;
if (d2 != 9) d2 <= d2 + 1; else begin d2 <= 0;
if (d3 != 5) d3 <= d3 + 1; else d3 <= 0; end end end
end
end
// multiplex about 1.5 kHz per digit
reg [17:0] mux = 0; always @(posedge clk) mux <= mux + 1;
reg [3:0] digit;
always @* begin
case (mux[17:16])
2'd0: begin an = 4'b1110; digit = d0; end
2'd1: begin an = 4'b1101; digit = d1; end
2'd2: begin an = 4'b1011; digit = d2; end
default: begin an = 4'b0111; digit = d3; end
endcase
case (digit) // gfedcba, active low
4'd0: seg = 7'b1000000; 4'd1: seg = 7'b1111001; 4'd2: seg = 7'b0100100; 4'd3: seg = 7'b0110000;
4'd4: seg = 7'b0011001; 4'd5: seg = 7'b0010010; 4'd6: seg = 7'b0000010; 4'd7: seg = 7'b1111000;
4'd8: seg = 7'b0000000; default: seg = 7'b0010000;
endcase
end
assign dp = ~(mux[17:16] == 2'd2); // dot after the seconds
endmodule
basys3.xdcset_property -dict { PACKAGE_PIN W5 IOSTANDARD LVCMOS33 } [get_ports clk]
create_clock -add -name sys_clk_pin -period 10.00 -waveform {0 5} [get_ports clk]
set_property -dict { PACKAGE_PIN W7 IOSTANDARD LVCMOS33 } [get_ports {seg[0]}]
set_property -dict { PACKAGE_PIN W6 IOSTANDARD LVCMOS33 } [get_ports {seg[1]}]
set_property -dict { PACKAGE_PIN U8 IOSTANDARD LVCMOS33 } [get_ports {seg[2]}]
set_property -dict { PACKAGE_PIN V8 IOSTANDARD LVCMOS33 } [get_ports {seg[3]}]
set_property -dict { PACKAGE_PIN U5 IOSTANDARD LVCMOS33 } [get_ports {seg[4]}]
set_property -dict { PACKAGE_PIN V5 IOSTANDARD LVCMOS33 } [get_ports {seg[5]}]
set_property -dict { PACKAGE_PIN U7 IOSTANDARD LVCMOS33 } [get_ports {seg[6]}]
set_property -dict { PACKAGE_PIN V7 IOSTANDARD LVCMOS33 } [get_ports dp]
set_property -dict { PACKAGE_PIN U2 IOSTANDARD LVCMOS33 } [get_ports {an[0]}]
set_property -dict { PACKAGE_PIN U4 IOSTANDARD LVCMOS33 } [get_ports {an[1]}]
set_property -dict { PACKAGE_PIN V4 IOSTANDARD LVCMOS33 } [get_ports {an[2]}]
set_property -dict { PACKAGE_PIN W4 IOSTANDARD LVCMOS33 } [get_ports {an[3]}]
set_property -dict { PACKAGE_PIN U18 IOSTANDARD LVCMOS33 } [get_ports btnC]
set_property -dict { PACKAGE_PIN T18 IOSTANDARD LVCMOS33 } [get_ports btnU]
The anodes are not multiplexing: check the an[] pin order in the XDC.
Use a lower mux bit (for example mux[16:15]) for a faster refresh.
The debounce counter is too short; widen cnt.
Each 4-bit counter maps directly to one digit, so no division is needed.
Yes, add two more BCD stages and use the LEDs or a second display.
Yes, the Standard edition supports the Artix-7 35T on the Basys 3.
1 part: Digilent Basys 3 Artix-7 FPGA Trainer Board. On this page you can tick the parts you already have and add only the rest to your cart.
It is a advanced project and takes about 3 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (stopwatch.v and basys3.xdc).
About ₹19,659 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Clock dividers and enables; BCD counters in Verilog; Multiplexing a seven-segment display; Using a constraints (XDC) file.
Your first MicroPython project: temperature and humidity on an OLED.
A web page with ON and OFF buttons that switches a relay over Wi-Fi.
A warm ring light that fades up at dusk and down at dawn.
Turn a Pi and a touchscreen into a home command centre with a clock and to-do list.
Learning project. Check every circuit and the datasheet of each part before you power it up.